diff --git a/js/HotgridView.js b/js/HotgridView.js index ca00017..6985290 100644 --- a/js/HotgridView.js +++ b/js/HotgridView.js @@ -14,6 +14,15 @@ class HotgridView extends ComponentView { this.setUpViewData(); } + remove() { + this.removePopupClosedListener(); + super.remove(); + } + + removePopupClosedListener() { + this.stopListening(Adapt, 'notify:closed', this.onPopupClosed); + } + setUpViewData() { this.popupView = null; this._isPopupOpen = false; @@ -45,19 +54,21 @@ class HotgridView extends ComponentView { model: this.model }); - notify.popup({ + this.notifyView = notify.popup({ _view: this.popupView, _isCancellable: true, _showCloseButton: false, _classes: 'hotgrid ' + this.model.get('_classes') }); - this.listenToOnce(Adapt, { - 'popup:closed': this.onPopupClosed + this.listenTo(Adapt, { + 'notify:closed': this.onPopupClosed }); } - onPopupClosed() { + onPopupClosed(view) { + if (view !== this.notifyView) return; + this.removePopupClosedListener(); this.model.getActiveItem().toggleActive(); this._isPopupOpen = false; }