javascript - Suppress / Silence Sammy.js route -


i've been trying suppress normal routing behavior in sammy.js router, far i've been unsuccessful.

this other answer isn't helpful 2 reasons:

  1. the upvoted answer "unacceptable" in situation, 1 of "soft" requirements route can silenced without knowledge be.
    in other words, route should defined normally, , internals of sammy should check option whether trigger route handler or not.

  2. the second answer -

    var new_location = '#foo'; app.trigger('redirect', {to: new_location}); app.last_location = ['get', new_location]; app.setlocation(new_location); 

    - doesn't work.

as simple example, parent object has method defined:

"navigate": function( href, options ){     var sammyapprouter = window.router;      if( !options ){         options = {};     }      if( options.silent ){         sammyapprouter.trigger( "redirect", { "to": href } );         sammyapprouter.last_location = [ "get", href ];     }      sammyapprouter.setlocation( href ); } 

(where window.router global sammy router)

at very simplest, goal only change url , have url listener ignore change. should possible on route otherwise matched, navigate( '/my-route' ) triggers handler, navigate( '/my-route', { "silent": true } ); changes url , not trigger handler.

is possible suppress sammy handlers on call-by-call basis?


Popular posts from this blog