Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alert the page no. on jQuery dataTables page change event

The following is working for me:

$('#datatable').on('page.dt', function() {
    alert("changed");
});

Whenever I am changing the page,the alert is shown.But if I want to alert the page no. which is clicked then what's the way

like image 867
sajju217 Avatar asked Aug 14 '14 10:08

sajju217


1 Answers

table.page.info() returns the current pagination information. That is current page, number of pages, recordsDisplay, recordsTotal and more.

var table = $('#datatable').DataTable();

$('#datatable').on('page.dt', function() {
    var info = table.page.info();
    var page = info.page+1;
    alert('changed - page '+page+' out of '+info.pages+' is clicked');
});

see demo -> http://jsfiddle.net/qpLtLfaz/

like image 142
davidkonrad Avatar answered Oct 15 '22 16:10

davidkonrad