Search code examples
jquerytablesorter

JQuery Tablesorter Pager: Get the currently viewed page number


I have looked through the documentation and a few examples but I can't find an answer to this...

How do you get the current page that is being viewed? It's for the purpose of limiting the number of results returned from a database.

Thanks

edit: updated the name because I realized how vague it was


Solution

  • If you are using the original version of tablesorter (v2.0.5), the page is contained in:

    // table.config.page = zero-based index
    // get the value as follows:
    var currentPage = $('table')[0].config.page;
    

    If you are using the pager from my fork of tablesorter, then you can get the page from (demo):

    // table.config.pager.page = zero-based page index
    var currentPage = $('table')[0].config.pager.page;
    

    or, if you are including the page select in the pager controls, use

    $('.gotoPage').val() // one-based page index