From e8f9624b42f9764de21c6e9552f55b18f9b48f82 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sun, 4 Mar 2012 21:58:00 +0100 Subject: [PATCH] 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 --- admin/javascript/LeftAndMain.EditForm.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/admin/javascript/LeftAndMain.EditForm.js b/admin/javascript/LeftAndMain.EditForm.js index 2649c1d2e..3debadd79 100644 --- a/admin/javascript/LeftAndMain.EditForm.js +++ b/admin/javascript/LeftAndMain.EditForm.js @@ -2,6 +2,14 @@ * File: LeftAndMain.EditForm.js */ (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($){ /** @@ -52,12 +60,6 @@ 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(), // in order to avoid changing the menu state if the action is cancelled by the user // $('.cms-menu')