Permalink
Browse files

BUGFIX Moved window.beforeunload handler out of onmatch(), was applie…

…d multiple times and causing unsaved changes confirmation messages on forms which were no longer loaded
  • Loading branch information...
1 parent c69e949 commit e8f9624b42f9764de21c6e9552f55b18f9b48f82 @chillu chillu committed Mar 4, 2012
Showing with 8 additions and 6 deletions.
  1. +8 −6 admin/javascript/LeftAndMain.EditForm.js
View
14 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')

0 comments on commit e8f9624

Please sign in to comment.