From a1ea07dc158616aa86160eba7f6764647b09c384 Mon Sep 17 00:00:00 2001 From: Mottie Date: Sun, 8 Dec 2013 22:11:32 -0600 Subject: [PATCH] Fix forced search --- docs/example-child-rows-filtered.html | 2 +- js/jquery.tablesorter.widgets.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/example-child-rows-filtered.html b/docs/example-child-rows-filtered.html index e26254d5..10f9e4ac 100644 --- a/docs/example-child-rows-filtered.html +++ b/docs/example-child-rows-filtered.html @@ -64,7 +64,7 @@ c.filter_childRows = o; $('.state').html(o.toString()); // update filter; include false parameter to force a new search - $('input.tablesorter-filter').trigger('search', false); + $('table').trigger('search', false); return false; }); diff --git a/js/jquery.tablesorter.widgets.js b/js/jquery.tablesorter.widgets.js index 1d8bce5f..b68b84d4 100644 --- a/js/jquery.tablesorter.widgets.js +++ b/js/jquery.tablesorter.widgets.js @@ -371,7 +371,7 @@ ts.addWidget({ $table .removeClass('hasFilters') // add .tsfilter namespace to all BUT search - .unbind('addRows updateCell update updateComplete appendCache search filterStart filterEnd '.split(' ').join('.tsfilter ')) + .unbind('addRows updateCell update updateRows updateComplete appendCache filterReset filterEnd search '.split(' ').join('.tsfilter ')) .find('.tablesorter-filter-row').remove(); for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) { $tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // remove tbody @@ -555,8 +555,7 @@ ts.filter = { } if (event.type === 'filterReset') { ts.filter.searching(table, []); - } - if (event.type === 'filterEnd') { + } else if (event.type === 'filterEnd') { ts.filter.buildDefault(table, true); } else { // send false argument to force a new search; otherwise if the filter hasn't changed, it will return @@ -754,7 +753,12 @@ ts.filter = { } // return if the last search is the same; but filter === false when updating the search // see example-widget-filter.html filter toggle buttons - if (c.lastCombinedFilter === combinedFilters && filter !== false) { return; } + if (c.lastCombinedFilter === combinedFilters && filter !== false) { + return; + } else if (filter === false) { + // force filter refresh + c.lastCombinedFilter = null; + } c.$table.trigger('filterStart', [filters]); if (c.showProcessing) { // give it time for the processing icon to kick in