简体   繁体   English

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

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

I'm using the jQuery tooltip for Datatable to show dynamic content. 我正在使用Datatable的jQuery工具提示来显示动态内容。 While loading the the dynamic content the tooltip of the old element stays after the new content has been loaded. 加载动态内容时,旧元素的工具提示会在新内容加载后保留。 I have seen exactly the same questions being asked, but the accepted answers does not seem to have work in my scenario. 我已经看到了完全相同的问题,但是在我的场景中似乎无法接受被接受的答案。 Below is the code of tooltip which I added to the whole document 以下是我添加到整个文档中的工具提示的代码

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

Changing the using: as below(as suggested by similar questions) does not solve my problem. 如下更改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 );
        }
    }
});

This is an old question, but an issue I've recently experienced. 这是一个老问题,但是我最近遇到了一个问题。 The solution I chose was to remove all tooltips from the page when the dynamic content is reloaded. 我选择的解决方案是在重新加载动态内容时从页面中删除所有工具提示。 If you are using the DataTables library, this would be in the drawCallback initialisation property. 如果您使用的是DataTables库,则将在drawCallback初始化属性中。

You can remove all tooltips like this: 您可以删除所有这样的工具提示:

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

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

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