I have the following code. It creates a form with a simple text box.
<div class="nav-bar"> <a href="#home">Home</a> <a href="#showform">Click here for the form</a> </div> <div id="theform"> <form> <input type="text" name="data" id="data" /> <input type="submit"> </form> </div>
After the user enters some data, he clicks on the home link. The highway starts navigation and calls the function for the house.
var AppRouter = Backbone.Router.extend({ routes: { "home": "home", "showform": "showtheform", }, home: function() { if (current_view) { cuttent_view.remove(); } current_view = new View_Home(); }, showtheform: function() {
After the handler, the form disappears, and unsaved changes remain unsaved (but cannot be saved later). Returning false in the router function does not affect anything, the URL changes anyway. How can I: a) prevent the URL from changing, and b) ask the user if he wants to save the unsaved changes?
source share