Sort2Hash: prevent filter update if unchanged

This commit is contained in:
Rob Garrison 2017-06-25 13:52:56 -05:00
parent 3415401d0b
commit a773ac63ed

View File

@ -1,4 +1,4 @@
/*! Widget: sort2Hash (BETA) - updated 4/2/2017 (v2.28.6) */ /*! Widget: sort2Hash (BETA) - updated 6/25/2017 (v2.28.15) */
/* Requires tablesorter v2.8+ and jQuery 1.7+ /* Requires tablesorter v2.8+ and jQuery 1.7+
* by Rob Garrison * by Rob Garrison
*/ */
@ -26,10 +26,21 @@
filter = filter.split( wo.sort2Hash_separator ); filter = filter.split( wo.sort2Hash_separator );
c.$table.one( 'tablesorter-ready', function() { c.$table.one( 'tablesorter-ready', function() {
setTimeout(function(){ setTimeout(function(){
c.$table.one( 'filterEnd', function(){ c.$table.one( 'filterEnd', function() {
$(this).triggerHandler( 'pageAndSize', [ page, size ] ); $(this).triggerHandler( 'pageAndSize', [ page, size ] );
}); });
// use the newest filter comparison code
if (ts.filter.equalFilters) {
temp = ts.filter.equalFilters(c, c.lastSearch, p.currentFilters);
} else {
// quick n' dirty comparison... it will miss filter changes of
// the same value in a different column, see #1363
temp = ( c.lastSearch || [] ).join( '' ) !== ( p.currentFilters || [] ).join( '' );
}
// don't set filters if they haven't changed
if ( !temp ) {
$.tablesorter.setFilters( table, filter, true ); $.tablesorter.setFilters( table, filter, true );
}
}, 100 ); }, 100 );
}); });
} }