By listening for attribute changes instead of "route" events, regular hrefs are not automatically picked up as routes. What would be the best practice to correct this?
For a link like:
- <a href="/app/test/">test</a>
… something like this seems a little excessive:
- can.route.bindings.pushstate.root = "/app/";
- can.route("", {section:""});
- can.route(":section/");
- can.route.ready();
- "a click": function(element, event)
- {
- var root = can.route.bindings.pushstate.root;
- var href = element.attr("href");
- if (href.indexOf(root) >= 0)
- {
- href = href.substr(root.length);
- var params = can.route.deparam(href);
- if ( !can.isEmptyObject(params) )
- {
- // {section:"test", route:":section/"}
- console.log(params);
- can.route.attr(params);
- event.preventDefault();
- }
- }
- }