Pager: use equalFilters for comparison. See #1384

This commit is contained in:
Rob Garrison 2017-04-11 14:57:33 -05:00
parent 39a1772b25
commit 07f9dd9f60
2 changed files with 16 additions and 7 deletions

View File

@ -968,11 +968,15 @@
.unbind( pagerEvents.split(' ').join(namespace + ' ').replace(/\s+/g, ' ') )
.bind('filterInit filterStart '.split(' ').join(namespace + ' '), function(e, filters) {
p.currentFilters = $.isArray(filters) ? filters : c.$table.data('lastSearch');
var filtersEqual;
if (ts.filter.equalFilters) {
filtersEqual = ts.filter.equalFilters(c, c.lastSearch, p.currentFilters);
} else {
// will miss filter changes of the same value in a different column, see #1363
filtersEqual = (c.lastSearch || []).join('') !== (p.currentFilters || []).join('');
}
// don't change page if filters are the same (pager updating, etc)
if (
e.type === 'filterStart' &&
p.pageReset !== false &&
(c.lastSearch || []).join(',') !== (p.currentFilters || []).join(',')) {
if (e.type === 'filterStart' && p.pageReset !== false && !filtersEqual) {
p.page = p.pageReset; // fixes #456 & #565
}
})

View File

@ -249,10 +249,15 @@
.off( namespace )
.on( 'filterInit filterStart '.split( ' ' ).join( namespace + ' ' ), function( e, filters ) {
p.currentFilters = $.isArray( filters ) ? filters : c.$table.data( 'lastSearch' );
var filtersEqual;
if (ts.filter.equalFilters) {
filtersEqual = ts.filter.equalFilters(c, c.lastSearch, p.currentFilters);
} else {
// will miss filter changes of the same value in a different column, see #1363
filtersEqual = ( c.lastSearch || [] ).join( '' ) !== ( p.currentFilters || [] ).join( '' );
}
// don't change page if filters are the same (pager updating, etc)
if ( e.type === 'filterStart' && wo.pager_pageReset !== false &&
( c.lastSearch || [] ).join( ',' ) !== ( p.currentFilters || [] ).join( ',' )
) {
if ( e.type === 'filterStart' && wo.pager_pageReset !== false && !filtersEqual ) {
p.page = wo.pager_pageReset; // fixes #456 & #565
}
})