From: Nicolas Coden Date: Thu, 1 Feb 2018 18:12:29 +0000 (+0100) Subject: fix: remove window events handler when ResponsiveAccordionTabs is destroyed #10901 X-Git-Tag: v6.6.0~3^2~308^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F10902%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git fix: remove window events handler when ResponsiveAccordionTabs is destroyed #10901 Closes https://github.com/zurb/foundation-sites/issues/10901 --- diff --git a/js/foundation.responsiveAccordionTabs.js b/js/foundation.responsiveAccordionTabs.js index 4ae87d81e..0ae378aaa 100644 --- a/js/foundation.responsiveAccordionTabs.js +++ b/js/foundation.responsiveAccordionTabs.js @@ -119,11 +119,8 @@ class ResponsiveAccordionTabs extends Plugin{ * @private */ _events() { - var _this = this; - - $(window).on('changed.zf.mediaquery', function() { - _this._checkMediaQueries(); - }); + this._changedZfMediaQueryHandler = this._checkMediaQueries.bind(this); + $(window).on('changed.zf.mediaquery', this._changedZfMediaQueryHandler); } /** @@ -234,7 +231,7 @@ class ResponsiveAccordionTabs extends Plugin{ */ _destroy() { if (this.currentPlugin) this.currentPlugin.destroy(); - $(window).off('.zf.ResponsiveAccordionTabs'); + $(window).off('changed.zf.mediaquery', this._changedZfMediaQueryHandler); } }