Detect page change on DataTable
With DataTable I can order, list, do pagination but I want to detect when the pagination changes, I've seen the API but the only one I can do is change the page but no detect this change.
Solution 1:
You may use fnDrawCallback or fnInfoCallback to detect changes, when next is clicked both of them are fired.
But beware, page changes are not the only source that can fire those callbacks.
For DataTables 1.10.0+
The option is now drawCallback
Solution 2:
Paging events are handled in this way,
$(document).ready(function() {
$('#example')
.on( 'order.dt', function () { console.log('Order' ); } )
.on( 'search.dt', function () {console.log('Search' ); } )
.on( 'page.dt', function () { console.log('Page' ); } )
.dataTable();
} );
documented in the official website, here http://www.datatables.net/examples/advanced_init/dt_events.html
The length.dt event is fired whenever the table's page length is changed
$('#example').dataTable();
$('#example').on( 'length.dt', function ( e, settings, len ) {
console.log( 'New page length: '+len );
} );
http://datatables.net/reference/event/length
More events here
datatables.net/reference/event/