I believe I have found a bug in the router control, with the routeMissing callback. According to the documentation, you should be able to call e.preventDefault() to cancel the navigation and stay on the current route.
This works as expected if I have a link on a page that points to an invalid route (ex. "#/missing") - the route is cancelled and I stay on the current view. But if I type the missing route (#/missing) into the browser address bar, then it reverts back to the route prior to the current route.
I have created an example in JS Bin that demonstrates this behavior - http://jsbin.com/EXARiTiJ/26
Here are the steps to recreate the issue:
This works as expected if I have a link on a page that points to an invalid route (ex. "#/missing") - the route is cancelled and I stay on the current view. But if I type the missing route (#/missing) into the browser address bar, then it reverts back to the route prior to the current route.
I have created an example in JS Bin that demonstrates this behavior - http://jsbin.com/EXARiTiJ/26
Here are the steps to recreate the issue:
- When the page loads, it will first navigate to the Home view
- Click on "Orders" to navigate to the Orders view. This will navigate correctly and update the url appropriately.
- Click "Missing" to navigate to a route that has not been defined. This will fire the routeMissing handler, which calls e.preventDefault() and reverts the url and the view back to "Orders"
- However, if you manually update the url in the address bar to "#/missing", the routeMissing handler fires and you are sent back to the Home view, and the url still has the invalid route (#/missing)
I am using the Q1 2014 release of the controls and testing in IE 10. I do not see the issue when testing with Google Chrome (v. 33)