悬停时的弹出窗口在数据表的第二页上不起作用 [英] popover on hover not working on second page of datatable
问题描述
我动态添加了一列的内容...
I added content of one column dynamically...
for (var i = 0; i < data.length; i++) {
data.referred_by='<a href="#" data-toggle="popover" class="" title="'+temp[i].referred_by+'"data-trigger="hover" data-content="Total Referrals :'+temp[i].as_count+'">'+temp[i].referred_by+'</a>'
}
以下代码是创建数据表
$('#datatable4').dataTable({
'paging': true, // Table pagination
'ordering': true, // Column ordering
'info': true, // Bottom left status text
"aaData" : data,
aoColumns: [
{ mData: 'index' },
{ mData: 'patient_name' },
{ mData: 'age' },
{ mData: 'gender' },
{ mData: 'mobile_no' },
{ mData: 'email_id' },
{ mData: 'request_status' },
{ mData: 'referred_by' },
{ mData: 'ref_to_img'},
{ mData: 'ref_by_img'}
]
在就绪函数中我添加了
$('[data-toggle="popover"]').popover();
但在数据表中,只有第一页的悬停弹出框有效......而在第二页之后它不起作用......有什么解决方案吗?
but in datatable only on first page popover on hover is working... and on second page onwards its not working.... is there any solution for this?
推荐答案
每次重绘 dataTable 时都需要重新初始化弹出框.$('[data-toggle="popover"]').popover()
只会初始化那些在代码执行时可见的弹出框,而不是例如第 2 页中的弹出框.在drawCallback()
中执行popover()
> 回调:
You need to reinitialize the popovers each time the dataTable is redrawn. $('[data-toggle="popover"]').popover()
will only initialize those popovers visible at the time the code is executed, not the popovers in for example page #2. Execute popover()
in the drawCallback()
callback instead :
$('#datatable4').dataTable({
...
drawCallback: function() {
$('[data-toggle="popover"]').popover();
}
})
这篇关于悬停时的弹出窗口在数据表的第二页上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!