Fixed page exit confirmation

This commit is contained in:
Marcin Kurczewski
2014-09-16 17:29:11 +02:00
parent ac312ccb49
commit d72c6c5d6e
2 changed files with 21 additions and 0 deletions

View File

@ -3,6 +3,7 @@ var App = App || {};
App.Router = function(pathJs, _, jQuery, util, appState, presenterManager) {
var root = '#/';
var previousLocation = window.location.href;
injectRoutes();
@ -57,6 +58,18 @@ App.Router = function(pathJs, _, jQuery, util, appState, presenterManager) {
{previousRoute: pathJs.routes.previous});
presenterManager.switchContentPresenter( presenterName, finalParams);
}).enter(function(e) {
if (util.isExitConfirmationEnabled()) {
if (window.location.href !== previousLocation) {
if (!window.confirm('Are you sure you want to leave this page? Data will be lost.')) {
window.location.href = previousLocation;
return false;
} else {
util.disableExitConfirmation();
}
}
}
previousLocation = window.location.href;
});
}