如何捕获DataTables下一个/上一个分页按钮上的事件

时间:2022-04-03 19:45:54

Can anybody show me an example of how to catch the events on pagination buttons next/previous of datatables? In particular I'm interested for the "next" button. It would really help me if you have an example of how to catch the event of a particular pagination button.

有人能告诉我一个如何捕获数据表下一个/上一个分页按钮事件的例子吗?特别是我对“下一步”按钮很感兴趣。如果您有一个如何捕获特定分页按钮事件的示例,那将对我有所帮助。

I have searched and in datatable and found that to catch an event you should use this :

我搜索并在datatable中发现要捕获一个事件你应该使用这个:

$('#example').on('page.dt', function ()).DataTable();

But this catches the events for all the pagination buttons. I want to know how to do it for a particular one("next" in my case).

但这会抓住所有分页按钮的事件。我想知道如何为特定的一个(在我的情况下为“下一个”)。

Thanks in advance

提前致谢

1 个解决方案

#1


4  

Use the code below to attach click event handler to "Next" pagination button.

使用下面的代码将click事件处理程序附加到“Next”分页按钮。

var table = $('#example').DataTable({
   drawCallback: function(){
      $('.paginate_button.next', this.api().table().container())          
         .on('click', function(){
            alert('next');
         });       
   }
});   

See this jsFiddle for code and demonstration.

有关代码和演示,请参阅此jsFiddle。

#1


4  

Use the code below to attach click event handler to "Next" pagination button.

使用下面的代码将click事件处理程序附加到“Next”分页按钮。

var table = $('#example').DataTable({
   drawCallback: function(){
      $('.paginate_button.next', this.api().table().container())          
         .on('click', function(){
            alert('next');
         });       
   }
});   

See this jsFiddle for code and demonstration.

有关代码和演示,请参阅此jsFiddle。