Skip to content

Commit

Permalink
added pager customAjaxUrl - See #256
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed Mar 28, 2013
1 parent 6fde718 commit aa0266c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ tablesorter can successfully parse and sort many types of data including linked

View the [complete listing here](https://github.com/Mottie/tablesorter/wiki/Change).

#### Version 2.8.1 (3/27/2013)

* Added `customAjaxUrl` option to the pager:
* This function is called after all processing has been applied to the `ajaxUrl` string.
* Use this function to make any other string modifications, as desired.
* Thanks to [Cthulhu59](https://github.com/Cthulhu59) for contributing. See [pull request #256](https://github.com/Mottie/tablesorter/pull/256).

#### Version 2.8 (3/27/2013)

* Added an `updateAll` method
Expand Down
20 changes: 10 additions & 10 deletions addons/pager/jquery.tablesorter.pager.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
// and a filterList = [[2,Blue],[3,13]] becomes "&fcol[2]=Blue&fcol[3]=13" in the url
ajaxUrl: null,

// modify the url after all processing has been applied
customAjaxUrl: function(table, url) { return url; },


// process ajax so that the following information is returned:
// [ total_rows (number), rows (array of arrays), headers (array; optional) ]
Expand Down Expand Up @@ -230,7 +230,7 @@
$f.eq(j).html( th[j] );
});
}

$t.find('thead tr.' + c.cssErrorRow).remove(); // Clean up any previous error.
if ( exception ) {
// add error row to thead instead of tbody, or clicking on the header will result in a parser error
Expand Down Expand Up @@ -273,18 +273,14 @@
});
}
},

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.replace(/\{page\}/g, c.page).replace(/\{size\}/g, c.size) : '',
sl = table.config.sortList,
fl = c.currentFilters || [],
sortCol = url.match(/\{sortList[\s+]?:[\s+]?([^}]*)\}/),
filterCol = url.match(/\{filterList[\s+]?:[\s+]?([^}]*)\}/),
arry = [];

if ( typeof(c.customAjaxUrl) === "function" ) {
url = c.customAjaxUrl(table, url);
}

if (sortCol) {
sortCol = sortCol[1];
Expand All @@ -304,7 +300,11 @@
// if the arry is empty, just add the fcol parameter... "&{filterList:fcol}" becomes "&fcol"
url = url.replace(/\{filterList[\s+]?:[\s+]?([^\}]*)\}/g, arry.length ? arry.join('&') : filterCol );
}


if ( typeof(c.customAjaxUrl) === "function" ) {
url = c.customAjaxUrl(table, url);
}

return url;
},

Expand Down Expand Up @@ -569,7 +569,7 @@
}

changeHeight(table, c);

// pager initialized
if (!c.ajax) {
c.initialized = true;
Expand Down
Loading

0 comments on commit aa0266c

Please sign in to comment.