如何捕获DataTables下一个/上一个分页按钮上的事件 [英] How to catch an event on pagination buttons next/previous of the DataTables
问题描述
有人能告诉我一个如何捕捉数据表下一个/上一个分页按钮事件的例子吗?
特别是我对下一步按钮感兴趣。如果您有一个如何捕获特定分页按钮事件的示例,那将对我有所帮助。
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 代码和演示。
这篇关于如何捕获DataTables下一个/上一个分页按钮上的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!