fixed recursive ajax pager issue #182

This commit is contained in:
Mottie 2012-11-27 17:39:53 -06:00
parent b74808e43a
commit 3275096e0a
6 changed files with 23 additions and 25 deletions

Binary file not shown.

View File

@ -1,8 +1,8 @@
/*! /*!
* tablesorter pager plugin * tablesorter pager plugin
* updated 11/15/2012 * updated 11/27/2012
*/ */
/*jshint browser:true, jquery:true */ /*jshint browser:true, jquery:true, unused:false */
;(function($) { ;(function($) {
"use strict"; "use strict";
$.extend({tablesorterPager: new function() { $.extend({tablesorterPager: new function() {
@ -231,7 +231,7 @@
} else { } else {
$b.html( tds ); // add tbody $b.html( tds ); // add tbody
} }
c.temp.remove(); // remove loading icon $.tablesorter.isProcessing(table); // remove loading icon
$t.trigger('update'); $t.trigger('update');
c.totalRows = result[0] || 0; c.totalRows = result[0] || 0;
c.totalPages = Math.ceil( c.totalRows / c.size ); c.totalPages = Math.ceil( c.totalRows / c.size );
@ -246,8 +246,7 @@
}, },
getAjax = function(table, c){ getAjax = function(table, c){
var $t = $(table), var url = (c.ajaxUrl) ? c.ajaxUrl.replace(/\{page\}/g, c.page).replace(/\{size\}/g, c.size) : '',
url = (c.ajaxUrl) ? c.ajaxUrl.replace(/\{page\}/g, c.page).replace(/\{size\}/g, c.size) : '',
arry = [], arry = [],
sl = table.config.sortList, sl = table.config.sortList,
col = url.match(/\{sortList[\s+]?:[\s+]?(.*)\}/); col = url.match(/\{sortList[\s+]?:[\s+]?(.*)\}/);
@ -261,12 +260,7 @@
} }
if ( url !== '' ) { if ( url !== '' ) {
// loading icon // loading icon
c.temp = $('<div/>', { $.tablesorter.isProcessing(table, true);
'class' : 'tablesorter-processing',
width : $t.outerWidth(true),
height: $t.outerHeight(true)
});
$t.before( c.temp );
$(document).ajaxError(function(e, xhr, settings, exception) { $(document).ajaxError(function(e, xhr, settings, exception) {
renderAjax(null, table, c, exception); renderAjax(null, table, c, exception);
}); });
@ -335,12 +329,13 @@
if ( c.page < 0 || c.page > ( p - 1 ) ) { if ( c.page < 0 || c.page > ( p - 1 ) ) {
c.page = 0; c.page = 0;
} }
$.data(table, 'pagerLastPage', c.page); // change if page changed - fixes #182
if ( c.ajax ) { if (c.ajax && $.data(table, 'pagerLastPage') !== c.page) {
getAjax(table, c); getAjax(table, c);
} else { } else if (!c.ajax) {
renderTable(table, table.config.rowsCopy, c); renderTable(table, table.config.rowsCopy, c);
} }
$.data(table, 'pagerLastPage', c.page);
if (c.initialized) { $(table).trigger('pageMoved', c); } if (c.initialized) { $(table).trigger('pageMoved', c); }
}, },
@ -387,6 +382,7 @@
enablePager = function(table, c, triggered){ enablePager = function(table, c, triggered){
var p = $(c.cssPageSize, c.container).removeClass(c.cssDisabled).removeAttr('disabled'); var p = $(c.cssPageSize, c.container).removeClass(c.cssDisabled).removeAttr('disabled');
$(c.container).find(c.cssGoto).removeClass(c.cssDisabled).removeAttr('disabled');
c.isDisabled = false; c.isDisabled = false;
c.page = $.data(table, 'pagerLastPage') || c.page || 0; c.page = $.data(table, 'pagerLastPage') || c.page || 0;
c.size = $.data(table, 'pagerLastSize') || parseInt(p.find('option[selected]').val(), 10) || c.size; c.size = $.data(table, 'pagerLastSize') || parseInt(p.find('option[selected]').val(), 10) || c.size;
@ -439,10 +435,12 @@
$(table) $(table)
.unbind('filterEnd.pager updateComplete.pager ') .unbind('filterEnd.pager updateComplete.pager ')
.bind('filterEnd.pager updateComplete.pager', function() { .bind('filterEnd.pager updateComplete.pager', function() {
if ($(this).hasClass('hasFilters')) {
c.page = 0; c.page = 0;
updatePageDisplay(table, c); updatePageDisplay(table, c);
moveToPage(table, c); moveToPage(table, c);
changeHeight(table, c); changeHeight(table, c);
}
}); });
if ( $(c.cssGoto, pager).length ) { if ( $(c.cssGoto, pager).length ) {

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*! /*!
* TableSorter 2.5.1 - Client-side table sorting with ease! * TableSorter 2.5.2 - Client-side table sorting with ease!
* @requires jQuery v1.2.6+ * @requires jQuery v1.2.6+
* *
* Copyright (c) 2007 Christian Bach * Copyright (c) 2007 Christian Bach
@ -23,7 +23,7 @@
var ts = this; var ts = this;
ts.version = "2.5.1"; ts.version = "2.5.2";
ts.parsers = []; ts.parsers = [];
ts.widgets = []; ts.widgets = [];

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "tablesorter", "name": "tablesorter",
"version": "2.5.1", "version": "2.5.2",
"title": "tablesorter", "title": "tablesorter",
"author": { "author": {
"name": "Christian Bach", "name": "Christian Bach",