I use canJs with plugin can.Map.delegate and i would like this, but it doesn't work, "ok" is not displaying in console.
Could you help me ?
$(function() { var Routing = can.Control({ '{can.route} id=3': function(data) { console.log("ok"); } }); var routeDelegate = can.route(":id"); can.route.ready(); routeDelegate.delegate("id", "set"); new Routing(document); can.route.attr("id", 3); });
Thank
What about using
can.Control.route
?http://canjs.com/docs/can.Control.route.html
This does all the simple mapping for you, you then have the params in the data object.
There is a nice 2 pager on this with both types of routes here:
http://bitovi.com/blog/2012/05/hashchange-routing-can-route-1.html
Note: I moved
can.route.ready();
to a bit later so a browser refresh will trigger the Control