繁体   English   中英

动态更改DataTable内容后,jQuery工具提示仍然存在

[英]Jquery tooltip stays after dynamic change of DataTable contents

我正在使用Datatable的jQuery工具提示来显示动态内容。 加载动态内容时,旧元素的工具提示会在新内容加载后保留。 我已经看到了完全相同的问题,但是在我的场景中似乎无法接受被接受的答案。 以下是我添加到整个文档中的工具提示的代码

$(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 :(由类似问题所建议)不能解决我的问题。

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 );
        }
    }
});

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

您可以删除所有这样的工具提示:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM