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).
Thanks in advance
DataTables can split the rows in tables into individual pages, which is an efficient method of showing a large number of records in a small space. The end user is provided with controls to request the display of different data as the navigate through the data.
You can add data-paging='false' to the <table> element and pagination will be disabled for that table. Save this answer. Show activity on this post. Here is an alternative that is an incremental improvement on several other answers.
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');
});
}
});
See this jsFiddle for code and demonstration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With