We have a backbone.js app that displays a number of forms to the user. What we want is very simple: if the user goes to another page without saving the filled-in form, we want t
Since version 1.2.0 you can override method Router.execute
and return false
to cancel routing, like this:
execute: function(callback, args, name) {
if (!changesAreSaved) {
// tip: .confirm returns false if "cancel" pressed
return window.confirm("You sure have some unsaved "
+ "work here, you want to abandon it?");
}
// this is the default part of "execute" - running the router action
if (callback)
callback.apply(this, args);
}