![](/img/trans.png)
[英]jQuery Dropdown that stays open after site-change – help a newbie
[英]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.