I have a Durandal app that allows the user to update various bits of profile information. For some bits of data, the user must click "save" to indicate they want to save their changes.
In the event that the user attempts to navigate away from the current view with unsaved changes, we want to intercept the navigation and popup a modal saying "you have unsaved changes--do you want to save them before leaving this view?"
However, in reviewing Durandal Router plugin documentation, I haven't been able to determine how to intercept navigation requests in my viewmodel. I think I want to listen for the router:route:activating event. But:
- I'm not sure where and how to setup the listener for this.
- I don't know how to cancel the navigation (so I can instead pop up my modal) in my event handler.