Browse Source

HUE-5812 [frontend] Add disposal logic to the niceScroll binding

Johan Ahlen 8 năm trước cách đây
mục cha
commit
44a13e0

+ 2 - 1
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -4618,7 +4618,7 @@
     init: function (element, valueAccessor, allBindings) {
       var options = valueAccessor() || {};
       if ((typeof options.enable === 'undefined' || options.enable) && $.fn.niceScroll) {
-        $(element).niceScroll({
+        var niceScroll = $(element).niceScroll({
           cursorcolor: "#C1C1C1",
           cursorborder: "1px solid #C1C1C1",
           cursoropacitymin: 0,
@@ -4629,6 +4629,7 @@
           horizrailenabled: typeof options.horizrailenabled !== 'undefined' ? options.horizrailenabled : true
         });
         $(element).addClass('nicescrollified');
+        ko.utils.domNodeDisposal.addDisposeCallback(element, niceScroll.remove);
       }
     }
   };