From 83c39b4dc64df326107ae0bfd2db9ae20b143060 Mon Sep 17 00:00:00 2001 From: Mottie Date: Thu, 4 Apr 2013 16:32:03 -0500 Subject: [PATCH] updated ajaxUrl to accept {page+#} tag; added all pager options to the main docs --- addons/pager/jquery.tablesorter.pager.js | 5 +- docs/example-pager-ajax.html | 16 +- docs/index.html | 393 ++++++++++++++++++++++- 3 files changed, 404 insertions(+), 10 deletions(-) diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index 2d28f0ae..c96b07b8 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -275,7 +275,10 @@ }, getAjaxUrl = function(table, c) { - var url = (c.ajaxUrl) ? c.ajaxUrl.replace(/\{page\}/g, c.page).replace(/\{size\}/g, c.size) : '', + var url = (c.ajaxUrl) ? c.ajaxUrl + // allow using "{page+1}" in the url string to switch to a non-zero based index + .replace(/\{page([\-+]\d+)?\}/, function(s,n){ return c.page + (n ? parseInt(n, 10) : 0); }) + .replace(/\{size\}/g, c.size) : '', sl = table.config.sortList, fl = c.currentFilters || [], sortCol = url.match(/\{sortList[\s+]?:[\s+]?([^}]*)\}/), diff --git a/docs/example-pager-ajax.html b/docs/example-pager-ajax.html index 7d1f5d5b..5069ab33 100644 --- a/docs/example-pager-ajax.html +++ b/docs/example-pager-ajax.html @@ -48,7 +48,8 @@ container: $(".pager"), // use this format: "http:/mydatabase.com?page={page}&size={size}&{sortList:col}" - // where {page} is replaced by the page number, {size} is replaced by the number of records to show, + // where {page} is replaced by the page number (or use {page+1} to get a one-based index), + // {size} is replaced by the number of records to show, // {sortList:col} adds the sortList to the url into a "col" array, and {filterList:fcol} adds // the filterList to the url into an "fcol" array. // So a sortList = [[2,0],[3,0]] becomes "&col[2]=0&col[3]=0" in the url @@ -59,8 +60,9 @@ customAjaxUrl: function(table, url) { // trigger my custom event $(table).trigger('changingUrl'); - // send the server the current page - return url += '¤tUrl=' + window.location.href; + // send the server the current page; separated & and "curr" + // because the browser things we're typing to use &curr; + return url += '&currntUrl=' + window.location.href; }, // process ajax so that the following information is returned: @@ -159,13 +161,13 @@

NOTE!: