knockout.js - Intercept route navigation and ask user "are you sure you wish to leave this page?" -
i have durandal app allows user update various bits of profile information. bits of data, user must click "save" indicate want save changes. in event user attempts navigate away current view unsaved changes, want intercept navigation , popup modal saying "you have unsaved changes--do want save them before leaving view?" however, in reviewing durandal router plugin documentation , haven't been able determine how intercept navigation requests in viewmodel. think want listen the router:route:activating event . but: i'm not sure , how setup listener this. i don't know how cancel navigation (so can instead pop modal) in event handler. you can in candeactivate event durandal has. var candeactivate = function () { // check if data has unsaved changes logic in haschanges() method if (haschanges()) { var msg = 'do want leave , cancel?'; return app.showmessage('message', 'confirm title', [...