Thursday, April 25, 2024
 Popular · Latest · Hot · Upcoming
72
rated 0 times [  78] [ 6]  / answers: 1 / hits: 25988  / 7 Years ago, fri, february 10, 2017, 12:00:00

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


More From » jquery

 Answers
90

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.


[#58986] Wednesday, February 8, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
elijahm

Total Points: 674
Total Questions: 124
Total Answers: 79

Location: Northern Mariana Islands
Member since Fri, Jan 15, 2021
3 Years ago
;