瀏覽代碼

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

Enrico Berti 9 年之前
父節點
當前提交
1e15595
共有 1 個文件被更改,包括 5 次插入2 次删除
  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 () {
-    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
       link = $("#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");