如何在数据表的下一个/上一个分页按钮上捕获事件 [英] How to catch an event on pagination buttons next/previous of the DataTables

查看:13
本文介绍了如何在数据表的下一个/上一个分页按钮上捕获事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以向我展示如何捕获数据表的下一个/上一个分页按钮上的事件的示例吗?我对下一步"按钮特别感兴趣.如果您有一个如何捕获特定分页按钮事件的示例,那真的对我有帮助.

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 :

$('#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).

提前致谢

推荐答案

使用下面的代码将单击事件处理程序附加到下一步"分页按钮.

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

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

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

See this jsFiddle for code and demonstration.

这篇关于如何在数据表的下一个/上一个分页按钮上捕获事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆