2015-11-18 66 views
1

我正在使用jQuery工具提示为Datatable显示动态内容。加载动态内容时,旧元素的工具提示在加载新内容后保留。 我已经看到完全相同的问题,但接受的答案似乎并没有在我的情况下工作。 下面的提示,我加入​​到整个文档Jquery工具提示在动态更改DataTable内容后保留

$(document).tooltip({ 
    position: { 
    my: "center top", 
    at: "center bottom+10", 
    using: function(position, feedback) { 

     $(this).css(position); 
     $("<div>") 
     .addClass("arrow") 
     .addClass(feedback.vertical) 
     .addClass(feedback.horizontal) 
     .appendTo(this); 
    } 
    } 
}); 

的使用更改代码:如下(按类似的问题的建议)并没有解决我的问题。

using: function(position, feedback) { 
      /* fix tooltip not hiding problem */ 
      if($(".ui-tooltip").length>1){ 
       // since the new tooltip is already added, there are now 2. 
       // removing the first one fixes the problem 
       $(".ui-tooltip")[0].remove(); 
      } 
      $(this).css(position); 
      $("<div>") 
      .addClass("arrow") 
      .addClass(feedback.vertical) 
      .addClass(feedback.horizontal) 
      .appendTo(this); 
     } 
    } 
}); 

回答

0

这是一个老问题,但一个问题,我最近经历。我选择的解决方案是在动态内容重新加载时从页面中删除所有工具提示。如果您正在使用DataTables库,则这将位于drawCallback初始化属性中。

可以删除所有的提示是这样的:

$(".ui-tooltip").remove();