在页面更改后,jQuery dataTables中的弹出窗口不起作用

时间:2021-10-24 20:08:27

Am using a JQUERY Datatable and Webui Popover plugin on my page. The popover actually assigned for an element in

我在我的页面上使用了JQUERY Datatable和Webui Popover插件。实际上为一个元素分配的popover

<small style=" color: #10336B;"  class='codedescription'  
data-title="My Title" data-content='My Dynamic Content'><b>CODE    

and here the Popover initialisation

这里是Popover的初始化

$('.codedescription').webuiPopover({ closeable: false, trigger: 'hover', title: '', content: '', delay: { show: null, hide: 300} });

Its working fine when the first page or just after the Datatable being binded. But if we move to another page on the datatable or after the page changed, the popover stopped working. Only the first time initialised popovers worked.

它在第一页或数据表被绑定之后工作正常。但是,如果我们移动到数据表上的另一个页面或页面更改后,弹出窗口停止工作。只有第一次初始化的popovers工作。

So I tried reinitialising the popover plugin at the Datatable page change event as follows.

所以我尝试在Datatable页面更改事件中重新初始化popover插件,如下所示。

$('#tbl_main').on('page.dt', function () {
    alert(55);
    $('.codedescription').webuiPopover({ closeable: false, trigger: 'hover', title: '', content: '', delay: { show: null, hide: 300} });
});

But when ever the page changes alert shows, but the popovers not showing in any pages other than the first page. What is making the popovers to not work after the page changes in JQUERY Datatable.

但是当页面更改警报显示时,但是弹出窗口没有显示在第一页以外的任何页面中。在JQUERY Datatable中页面更改后,什么使popovers不起作用。

1 个解决方案

#1


You should use the draw.dt event. page.dt is triggered when the table's paging is updated, draw.dt is triggered when the dataTable has completed a draw.

您应该使用draw.dt事件。更新表的分页时会触发page.dt,当dataTable完成绘图时会触发draw.dt。

$('#tbl_main').on('draw.dt', function () {
   ...
});

#1


You should use the draw.dt event. page.dt is triggered when the table's paging is updated, draw.dt is triggered when the dataTable has completed a draw.

您应该使用draw.dt事件。更新表的分页时会触发page.dt,当dataTable完成绘图时会触发draw.dt。

$('#tbl_main').on('draw.dt', function () {
   ...
});