Figured out how to avoid hardcoding the instance.

This commit is contained in:
George Stephanis 2015-08-10 16:23:44 -04:00
parent ccd1734353
commit 59a1a313a6
1 changed files with 2 additions and 3 deletions

View File

@ -63,7 +63,7 @@
this.qty_pages = Math.ceil( this.model.get( 'rates' ).length / this.per_page );
this.listenTo( this.model, 'change', this.setUnloadConfirmation );
this.listenTo( this.model, 'saved', this.clearUnloadConfirmation );
$(window).on( 'beforeunload', this.unloadConfirmation );
$(window).on( 'beforeunload', { view : this }, this.unloadConfirmation );
},
setUnloadConfirmation : function() {
this.needsUnloadConfirm = true;
@ -72,8 +72,7 @@
this.needsUnloadConfirm = false;
},
unloadConfirmation : function(e) {
// @todo: Find a way to stop needing to refer to the specific instance from the abstract class.
if ( WCTaxTableInstance.needsUnloadConfirm ) {
if ( e.data.view.needsUnloadConfirm ) {
e.returnValue = data.strings.unload_confirmation_msg;
window.event.returnValue = data.strings.unload_confirmation_msg;
return data.strings.unload_confirmation_msg;