BUGFIX Moved window.beforeunload handler out of onmatch(), was applied multiple times and causing unsaved changes confirmation messages on forms which were no longer loaded

This commit is contained in:
Ingo Schommer 2012-03-04 21:58:00 +01:00
parent c69e949bc9
commit e8f9624b42

View File

@ -2,6 +2,14 @@
* File: LeftAndMain.EditForm.js * File: LeftAndMain.EditForm.js
*/ */
(function($) { (function($) {
// Can't bind this through jQuery
window.onbeforeunload = function(e) {
var form = $('.cms-edit-form');
form.trigger('beforesave');
if(form.is('.changed')) return ss.i18n._t('LeftAndMain.CONFIRMUNSAVEDSHORT');
};
$.entwine('ss', function($){ $.entwine('ss', function($){
/** /**
@ -52,12 +60,6 @@
this._setupChangeTracker(); this._setupChangeTracker();
// Can't bind this through jQuery
window.onbeforeunload = function(e) {
self.trigger('beforesave');
if(self.is('.changed')) return ss.i18n._t('LeftAndMain.CONFIRMUNSAVEDSHORT');
};
// Catch navigation events before they reach handleStateChange(), // Catch navigation events before they reach handleStateChange(),
// in order to avoid changing the menu state if the action is cancelled by the user // in order to avoid changing the menu state if the action is cancelled by the user
// $('.cms-menu') // $('.cms-menu')