Merge pull request #256 from Cthulhu59/master

Add parameters to ajx url
This commit is contained in:
Rob G 2013-03-27 17:16:06 -07:00
commit 6fde718ec1

View File

@ -20,6 +20,9 @@
// and a filterList = [[2,Blue],[3,13]] becomes "&fcol[2]=Blue&fcol[3]=13" in the url // and a filterList = [[2,Blue],[3,13]] becomes "&fcol[2]=Blue&fcol[3]=13" in the url
ajaxUrl: null, ajaxUrl: null,
customAjaxUrl: function(table, url) { return url; },
// process ajax so that the following information is returned: // process ajax so that the following information is returned:
// [ total_rows (number), rows (array of arrays), headers (array; optional) ] // [ total_rows (number), rows (array of arrays), headers (array; optional) ]
// example: // example:
@ -272,12 +275,17 @@
}, },
getAjaxUrl = function(table, c) { 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, sl = table.config.sortList,
fl = c.currentFilters || [], fl = c.currentFilters || [],
sortCol = url.match(/\{sortList[\s+]?:[\s+]?([^}]*)\}/), sortCol = url.match(/\{sortList[\s+]?:[\s+]?([^}]*)\}/),
filterCol = url.match(/\{filterList[\s+]?:[\s+]?([^}]*)\}/), filterCol = url.match(/\{filterList[\s+]?:[\s+]?([^}]*)\}/),
arry = []; arry = [];
if ( typeof(c.customAjaxUrl) === "function" ) {
url = c.customAjaxUrl(table, url);
}
if (sortCol) { if (sortCol) {
sortCol = sortCol[1]; sortCol = sortCol[1];
$.each(sl, function(i,v){ $.each(sl, function(i,v){
@ -577,4 +585,4 @@ $.fn.extend({
tablesorterPager: $.tablesorterPager.construct tablesorterPager: $.tablesorterPager.construct
}); });
})(jQuery); })(jQuery);