From a773ac63edc30ebd2cb46995c022fa238c2bf515 Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Sun, 25 Jun 2017 13:52:56 -0500 Subject: [PATCH] Sort2Hash: prevent filter update if unchanged --- js/widgets/widget-sort2Hash.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/js/widgets/widget-sort2Hash.js b/js/widgets/widget-sort2Hash.js index 7429bf8a..46c1d178 100644 --- a/js/widgets/widget-sort2Hash.js +++ b/js/widgets/widget-sort2Hash.js @@ -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+ * by Rob Garrison */ @@ -26,10 +26,21 @@ filter = filter.split( wo.sort2Hash_separator ); c.$table.one( 'tablesorter-ready', function() { setTimeout(function(){ - c.$table.one( 'filterEnd', function(){ + c.$table.one( 'filterEnd', function() { $(this).triggerHandler( 'pageAndSize', [ page, size ] ); }); - $.tablesorter.setFilters( table, filter, true ); + // 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 ); + } }, 100 ); }); }