From 59a1a313a67ebd259a326983a1432a6920a8f2f4 Mon Sep 17 00:00:00 2001 From: George Stephanis Date: Mon, 10 Aug 2015 16:23:44 -0400 Subject: [PATCH] Figured out how to avoid hardcoding the instance. --- assets/js/admin/settings-views-html-settings-tax.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/assets/js/admin/settings-views-html-settings-tax.js b/assets/js/admin/settings-views-html-settings-tax.js index 322fdb7c78d..ba4c5a2a66b 100644 --- a/assets/js/admin/settings-views-html-settings-tax.js +++ b/assets/js/admin/settings-views-html-settings-tax.js @@ -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;