Hey, I think I am trying to do the same thing.
I want to replace a route callback in my app after it is running,
based on some info that is returned via ajax before
for example:
My app first loads available routes via json and maps them via
mapRoutes.
On some routes, an ajax call returns a url.
This url is to be used(by partial) in a new callback for the current
route.
I realize that I could just use the url directly, but I'd like the
route to continue being available after
I am not sure what function to use in order to get the route to re-run
after the replacement.
Here is my hack for a replaceRoute function in a new fork of Sammy.js:
http://github.com/misterinterrupt/sammy/commit/76a8abb60b95d5d8a7cefb5abf58256cf2917357
I am unsure whether this is actually working.. Could someone try to
use this function ? I am attempting to use this outside of the app in
an ajax callback like so:
http://pastebin.com/fU7yrihX
On Nov 1, 11:01 pm, Aaron Quint <
aa...@quirkey.com> wrote:
> You might benefit from using plugins as simple closures.
>
> var myApp = $.sammy(function(app){
> app.get('#/',function(){
> ...
> });
>
> app.get('#/:id/:page',function(){
> ...
> })
>
> }).run('#/');
>
> myApp.use(function() {
> this.get('#/:id/:page',function(){
> ...do this instead
> });
>
> });
>
> That still doesnt solve your problem, though. I guess what you're assuming
> (which is not entirely incorrect) is that routes are more like an object
> with paths as keys. So adding a route with the same path should update it.
> All paths in fact are just turned into RegExp's even if they start out as
> strings. I guess I could still compare the new RegExps to existing ones, but
> I have a feeling that might result in some strange behavior. Possibly worth
> a try, though. You could hack `route()` to add any route to the begining of
> the array instead of the end as well. Any other ideas?
> --AQ
>
> Aaron Quinthttp://
www.quirkey.com
> > <
sammyjs%2Bunsu...@googlegroups.com<
sammyjs%252Buns...@googlegroups.com>>