]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fix: remove window events handler when ResponsiveAccordionTabs is destroyed #10901 10902/head
authorNicolas Coden <nicolas@ncoden.fr>
Thu, 1 Feb 2018 18:12:29 +0000 (19:12 +0100)
committerNicolas Coden <nicolas@ncoden.fr>
Thu, 1 Feb 2018 18:12:29 +0000 (19:12 +0100)
Closes https://github.com/zurb/foundation-sites/issues/10901

js/foundation.responsiveAccordionTabs.js

index 4ae87d81e4460f1c32bdddbe55828a6f74058eec..0ae378aaabcf5344ed49c5ceeb6bbd9abfe33b5b 100644 (file)
@@ -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);
   }
 }