mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Pager: restore settings on resetToLoadState
. Fixes #1311
This commit is contained in:
parent
b093f5af60
commit
95251fd21a
@ -858,6 +858,12 @@
|
||||
updatePageDisplay(table, p);
|
||||
},
|
||||
|
||||
resetState = function(table, p) {
|
||||
var c = table.config;
|
||||
c.pager = $.extend( true, {}, $.tablesorterPager.defaults, p.settings );
|
||||
init(table, p.settings);
|
||||
},
|
||||
|
||||
destroyPager = function(table, p) {
|
||||
var c = table.config,
|
||||
namespace = c.namespace + 'pager',
|
||||
@ -914,28 +920,10 @@
|
||||
console.log('Pager: Enabled');
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
$this.appender = function(table, rows) {
|
||||
var c = table.config,
|
||||
p = c.pager;
|
||||
if ( !p.ajax ) {
|
||||
c.rowsCopy = rows;
|
||||
p.totalRows = p.countChildRows ? c.$tbodies.eq(0).children('tr').length : rows.length;
|
||||
p.size = $.data(table, 'pagerLastSize') || p.size || p.settings.size || 10;
|
||||
p.totalPages = p.size === 'all' ? 1 : Math.ceil( p.totalRows / p.size );
|
||||
renderTable(table, rows, p);
|
||||
// update display here in case all rows are removed
|
||||
updatePageDisplay(table, p, false);
|
||||
}
|
||||
};
|
||||
|
||||
$this.construct = function(settings) {
|
||||
return this.each(function() {
|
||||
// check if tablesorter has initialized
|
||||
if (!(this.config && this.hasInitialized)) { return; }
|
||||
init = function(table, settings) {
|
||||
var t, ctrls, fxn, size,
|
||||
table = this,
|
||||
c = table.config,
|
||||
wo = c.widgetOptions,
|
||||
p = c.pager = $.extend( true, {}, $.tablesorterPager.defaults, settings ),
|
||||
@ -997,6 +985,10 @@
|
||||
e.stopPropagation();
|
||||
destroyPager(table, p);
|
||||
})
|
||||
.bind('resetToLoadState' + namespace, function(e){
|
||||
e.stopPropagation();
|
||||
resetState(table, p);
|
||||
})
|
||||
.bind('updateComplete' + namespace, function(e, table, triggered){
|
||||
e.stopPropagation();
|
||||
// table can be unintentionally undefined in tablesorter v2.17.7 and earlier
|
||||
@ -1132,6 +1124,27 @@
|
||||
|
||||
// make the hasWidget function think that the pager widget is being used
|
||||
c.widgetInit.pager = true;
|
||||
};
|
||||
|
||||
$this.appender = function(table, rows) {
|
||||
var c = table.config,
|
||||
p = c.pager;
|
||||
if ( !p.ajax ) {
|
||||
c.rowsCopy = rows;
|
||||
p.totalRows = p.countChildRows ? c.$tbodies.eq(0).children('tr').length : rows.length;
|
||||
p.size = $.data(table, 'pagerLastSize') || p.size || p.settings.size || 10;
|
||||
p.totalPages = p.size === 'all' ? 1 : Math.ceil( p.totalRows / p.size );
|
||||
renderTable(table, rows, p);
|
||||
// update display here in case all rows are removed
|
||||
updatePageDisplay(table, p, false);
|
||||
}
|
||||
};
|
||||
|
||||
$this.construct = function(settings) {
|
||||
return this.each(function() {
|
||||
// check if tablesorter has initialized
|
||||
if (!(this.config && this.hasInitialized)) { return; }
|
||||
init(this, settings);
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user