mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Filter: fix filter initialization intermittently stalling
This commit is contained in:
parent
98e3a41428
commit
443f963567
@ -657,7 +657,7 @@ ts.filter = {
|
|||||||
$(document)
|
$(document)
|
||||||
.undelegate(wo.filter_reset, 'click.tsfilter')
|
.undelegate(wo.filter_reset, 'click.tsfilter')
|
||||||
.delegate(wo.filter_reset, 'click.tsfilter', function() {
|
.delegate(wo.filter_reset, 'click.tsfilter', function() {
|
||||||
// trigger a reset event, so other functions (filterFormatter) know when to reset
|
// trigger a reset event, so other functions (filter_formatter) know when to reset
|
||||||
c.$table.trigger('filterReset');
|
c.$table.trigger('filterReset');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -764,23 +764,27 @@ ts.filter = {
|
|||||||
completed = function(){
|
completed = function(){
|
||||||
wo.filter_initialized = true;
|
wo.filter_initialized = true;
|
||||||
c.$table.trigger('filterInit', c);
|
c.$table.trigger('filterInit', c);
|
||||||
ts.filter.findRows(c.table, c.$table.data('lastSearch'), null);
|
ts.filter.findRows(c.table, c.$table.data('lastSearch') || []);
|
||||||
};
|
};
|
||||||
$.each( wo.filter_formatterInit, function(i, val) {
|
if ( $.isEmptyObject( wo.filter_formatter ) ) {
|
||||||
if (val === 1) {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
clearTimeout(wo.filter_initTimer);
|
|
||||||
if (!wo.filter_initialized && count === wo.filter_formatterCount) {
|
|
||||||
// filter widget initialized
|
|
||||||
completed();
|
completed();
|
||||||
} else if (!wo.filter_initialized) {
|
} else {
|
||||||
// fall back in case a filter_formatter doesn't call
|
$.each( wo.filter_formatterInit, function(i, val) {
|
||||||
// $.tablesorter.filter.formatterUpdated($cell, column), and the count is off
|
if (val === 1) {
|
||||||
wo.filter_initTimer = setTimeout(function(){
|
count++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
clearTimeout(wo.filter_initTimer);
|
||||||
|
if (!wo.filter_initialized && count === wo.filter_formatterCount) {
|
||||||
|
// filter widget initialized
|
||||||
completed();
|
completed();
|
||||||
}, 500);
|
} else if (!wo.filter_initialized) {
|
||||||
|
// fall back in case a filter_formatter doesn't call
|
||||||
|
// $.tablesorter.filter.formatterUpdated($cell, column), and the count is off
|
||||||
|
wo.filter_initTimer = setTimeout(function(){
|
||||||
|
completed();
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1114,10 +1118,16 @@ ts.filter = {
|
|||||||
$(this).hasClass('filter-parsed');
|
$(this).hasClass('filter-parsed');
|
||||||
}).get();
|
}).get();
|
||||||
|
|
||||||
if (c.debug) { time = new Date(); }
|
if (c.debug) {
|
||||||
|
ts.log('Starting filter widget search', filters);
|
||||||
|
time = new Date();
|
||||||
|
}
|
||||||
// filtered rows count
|
// filtered rows count
|
||||||
c.filteredRows = 0;
|
c.filteredRows = 0;
|
||||||
c.totalRows = 0;
|
c.totalRows = 0;
|
||||||
|
// combindedFilters are undefined on init
|
||||||
|
combinedFilters = (filters || []).join('');
|
||||||
|
|
||||||
for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
|
for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
|
||||||
if ($tbodies.eq(tbodyIndex).hasClass(c.cssInfoBlock || ts.css.info)) { continue; } // ignore info blocks, issue #264
|
if ($tbodies.eq(tbodyIndex).hasClass(c.cssInfoBlock || ts.css.info)) { continue; } // ignore info blocks, issue #264
|
||||||
$tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true);
|
$tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true);
|
||||||
|
Loading…
Reference in New Issue
Block a user