Browse Source

HUE-4718 [core] jHueScrollUp pollutes the DOM with more than one scroll up anchor

Enrico Berti 9 years ago
parent
commit
1e15595a17
1 changed files with 5 additions and 2 deletions
  1. 5 2
      desktop/core/src/desktop/static/desktop/js/jquery.scrollup.js

+ 5 - 2
desktop/core/src/desktop/static/desktop/js/jquery.scrollup.js

@@ -44,13 +44,16 @@
   };
   };
 
 
   Plugin.prototype.init = function () {
   Plugin.prototype.init = function () {
-    var _this = this;
+    var _this = this,
+      link = null;
 
 
-    var link = $("<a/>").attr("id", "jHueScrollUpAnchor").addClass("hueAnchor").attr("href", "javascript:void(0)").html("<i class='fa fa-chevron-up'></i>").appendTo("body");
     if ($("#jHueScrollUpAnchor").length > 0) { // just one scroll up per page
     if ($("#jHueScrollUpAnchor").length > 0) { // just one scroll up per page
       link = $("#jHueScrollUpAnchor");
       link = $("#jHueScrollUpAnchor");
       $(document).off("click", "#jHueScrollUpAnchor");
       $(document).off("click", "#jHueScrollUpAnchor");
     }
     }
+    else {
+      link = $("<a/>").attr("id", "jHueScrollUpAnchor").addClass("hueAnchor").attr("href", "javascript:void(0)").html("<i class='fa fa-chevron-up'></i>").appendTo("body");
+    }
 
 
     $(_this.element).attr("jHueScrollified", "true");
     $(_this.element).attr("jHueScrollified", "true");