Pagination: .on("page" function(){}), and current list

Pagination: .on("page" function(){}), and current list

jeffwjeffw Posts: 38Questions: 5Answers: 0
edited April 2014 in General
Is there a way to call the page method and have it see the target rows instead of the start rows? When I try to access the table from within the .on('page') callback function, e.g.

$(this).find('tbody tr').length

it's seeing the content in the first page (i.e. before I click Next), not the second page. Is there a way for the 'new' content to be visible inside the callback function?

Many thanks for a great plugin.

Replies

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Hi,

    The `page` event is triggered before the new draw - it is is done when the data is changed internally, which is why you aren't yet seeing the new data. The new documentation for the event notes this: http://next.datatables.net/reference/event/page .

    If you want to get the newly paged information you need to combine it with a draw event. You could do something like:

    [code]
    table.on( 'page', function () {
    table.one( 'draw', function () {
    ...
    } );
    } );
    [/code]

    Regards,
    Allan
  • jeffwjeffw Posts: 38Questions: 5Answers: 0
    Works great; many thanks Allan.
This discussion has been closed.