From 6fbce2b35c1497164069059f2d56f945372c7f35 Mon Sep 17 00:00:00 2001 From: Cthulhu59 Date: Mon, 11 Mar 2013 17:14:17 +0100 Subject: [PATCH] Add custom ajax url to add custom params to url --- addons/pager/jquery.tablesorter.pager.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index fa0275ad..ee7e0f85 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -20,6 +20,9 @@ // and a filterList = [[2,Blue],[3,13]] becomes "&fcol[2]=Blue&fcol[3]=13" in the url ajaxUrl: null, + 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) ] // example: @@ -272,12 +275,17 @@ }, 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]; $.each(sl, function(i,v){ @@ -571,4 +579,4 @@ $.fn.extend({ tablesorterPager: $.tablesorterPager.construct }); -})(jQuery); \ No newline at end of file +})(jQuery);