mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Pager: unbind pager controls on destroy. Fixes #981
This commit is contained in:
parent
12e82fd46e
commit
d8fd020d29
@ -801,16 +801,23 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
destroyPager = function(table, p) {
|
destroyPager = function(table, p) {
|
||||||
|
var c = table.config,
|
||||||
|
namespace = c.namespace + 'pager',
|
||||||
|
ctrls = [ p.cssFirst, p.cssPrev, p.cssNext, p.cssLast, p.cssGoto, p.cssPageSize ].join( ',' );
|
||||||
showAllRows(table, p);
|
showAllRows(table, p);
|
||||||
p.$container.hide(); // hide pager
|
p.$container
|
||||||
var c = table.config;
|
// hide pager controls
|
||||||
|
.hide()
|
||||||
|
// unbind
|
||||||
|
.find( ctrls )
|
||||||
|
.unbind( namespace );
|
||||||
c.appender = null; // remove pager appender function
|
c.appender = null; // remove pager appender function
|
||||||
p.initialized = false;
|
c.$table.unbind( namespace );
|
||||||
delete c.rowsCopy;
|
|
||||||
$(table).unbind( pagerEvents.split(' ').join(c.namespace + 'pager ').replace(/\s+/g, ' ') );
|
|
||||||
if (ts.storage) {
|
if (ts.storage) {
|
||||||
ts.storage(table, p.storageKey, '');
|
ts.storage(table, p.storageKey, '');
|
||||||
}
|
}
|
||||||
|
delete c.pager;
|
||||||
|
delete c.rowsCopy;
|
||||||
},
|
},
|
||||||
|
|
||||||
enablePager = function(table, p, triggered) {
|
enablePager = function(table, p, triggered) {
|
||||||
@ -888,6 +895,7 @@
|
|||||||
p.regexRows = new RegExp('(' + (wo.filter_filteredRow || 'filtered') + '|' + c.selectorRemove.slice(1) + '|' + c.cssChildRow + ')');
|
p.regexRows = new RegExp('(' + (wo.filter_filteredRow || 'filtered') + '|' + c.selectorRemove.slice(1) + '|' + c.cssChildRow + ')');
|
||||||
|
|
||||||
$t
|
$t
|
||||||
|
// .unbind( namespace ) adding in jQuery 1.4.3 ( I think )
|
||||||
.unbind( pagerEvents.split(' ').join(namespace + ' ').replace(/\s+/g, ' ') )
|
.unbind( pagerEvents.split(' ').join(namespace + ' ').replace(/\s+/g, ' ') )
|
||||||
.bind('filterInit filterStart '.split(' ').join(namespace + ' '), function(e, filters) {
|
.bind('filterInit filterStart '.split(' ').join(namespace + ' '), function(e, filters) {
|
||||||
p.currentFilters = $.isArray(filters) ? filters : c.$table.data('lastSearch');
|
p.currentFilters = $.isArray(filters) ? filters : c.$table.data('lastSearch');
|
||||||
|
File diff suppressed because one or more lines are too long
2
dist/js/widgets/widget-pager.min.js
vendored
2
dist/js/widgets/widget-pager.min.js
vendored
File diff suppressed because one or more lines are too long
@ -144,9 +144,7 @@
|
|||||||
last: {},
|
last: {},
|
||||||
// save original pager size
|
// save original pager size
|
||||||
setSize: wo.pager_size,
|
setSize: wo.pager_size,
|
||||||
setPage: wo.pager_startPage,
|
setPage: wo.pager_startPage
|
||||||
events: 'filterInit filterStart filterEnd sortEnd disablePager enablePager destroyPager updateComplete ' +
|
|
||||||
'pageSize pageSet pageAndSize pagerUpdate refreshComplete '
|
|
||||||
}, c.pager);
|
}, c.pager);
|
||||||
|
|
||||||
// pager initializes multiple times before table has completed initialization
|
// pager initializes multiple times before table has completed initialization
|
||||||
@ -236,7 +234,7 @@
|
|||||||
s = wo.pager_selectors;
|
s = wo.pager_selectors;
|
||||||
|
|
||||||
c.$table
|
c.$table
|
||||||
.off( $.trim(p.events.split(' ').join(namespace + ' ')) )
|
.off( namespace )
|
||||||
.on('filterInit filterStart '.split(' ').join(namespace + ' '), function(e, filters) {
|
.on('filterInit filterStart '.split(' ').join(namespace + ' '), function(e, filters) {
|
||||||
p.currentFilters = $.isArray(filters) ? filters : c.$table.data('lastSearch');
|
p.currentFilters = $.isArray(filters) ? filters : c.$table.data('lastSearch');
|
||||||
// don't change page if filters are the same (pager updating, etc)
|
// don't change page if filters are the same (pager updating, etc)
|
||||||
@ -1073,17 +1071,25 @@
|
|||||||
|
|
||||||
destroyPager: function(table, c, refreshing){
|
destroyPager: function(table, c, refreshing){
|
||||||
var p = c.pager,
|
var p = c.pager,
|
||||||
|
s = c.widgetOptions.pager_selectors,
|
||||||
|
ctrls = [ s.first, s.prev, s.next, s.last, s.gotoPage, s.pageSize ].join( ',' ),
|
||||||
namespace = c.namespace + 'pager';
|
namespace = c.namespace + 'pager';
|
||||||
p.initialized = false;
|
p.initialized = false;
|
||||||
c.$table.off( $.trim(p.events.split(' ').join(namespace + ' ')) );
|
c.$table.off( namespace );
|
||||||
if (refreshing) { return; }
|
p.$container
|
||||||
|
// hide pager
|
||||||
|
.hide()
|
||||||
|
// unbind pager controls
|
||||||
|
.find( ctrls )
|
||||||
|
.off( namespace );
|
||||||
|
if ( refreshing ) { return; }
|
||||||
tsp.showAllRows(table, c);
|
tsp.showAllRows(table, c);
|
||||||
p.$container.hide(); // hide pager
|
|
||||||
c.appender = null; // remove pager appender function
|
c.appender = null; // remove pager appender function
|
||||||
delete table.config.rowsCopy;
|
|
||||||
if (ts.storage) {
|
if (ts.storage) {
|
||||||
ts.storage(table, c.widgetOptions.pager_storageKey, '');
|
ts.storage(table, c.widgetOptions.pager_storageKey, '');
|
||||||
}
|
}
|
||||||
|
delete table.config.pager;
|
||||||
|
delete table.config.rowsCopy;
|
||||||
},
|
},
|
||||||
|
|
||||||
enablePager: function(table, c, triggered){
|
enablePager: function(table, c, triggered){
|
||||||
|
Loading…
Reference in New Issue
Block a user