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
I would avoid hacking around with Backbone. You could do this globally for all links by replacing the part where you would normally start Backbone.history
with something like
initRouter: function () {
Backbone.history.start({ pushState: true });
$(document).on('click', 'a', function (ev) {
var href = $(this).attr('href');
ev.preventDefault();
if (changesAreSaved) {
router.navigate(href, true);
}
});
}
You need of course to replace the changesAreSaved
with something that makes sense and add whatever other login you have about handling links.