Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,12 @@
var vals = [];

criteria.$ele.filter(criteria.selector).each(function() {
vals.push($(this).val());
var value = $(this).val();
if (value instanceof Array) {
vals = vals.concat(value);
} else {
vals.push(value);
}
});

if(criteria.type == 'range'){
Expand Down Expand Up @@ -325,15 +330,23 @@

//Search
var bindSearchEvent = function(searchBox, timeout, context){
$('body').on('keyup', searchBox, function(e){
var handler = function(e){
if (context.searchTimeoutId) {
clearTimeout(context.searchTimeoutId);
}
context.searchTimeoutId = setTimeout(function() {
context.filter();
}, timeout);
//context.searchFilter(true);
});
};
$('body').on('keyup', searchBox, handler);
return handler;
};

var unbindSearchEvent = function(searchBox, handler){
if (handler) {
$('body').off('keyup', searchBox, handler);
}
};

F.initSearch = function(opts){
Expand All @@ -350,7 +363,8 @@
if(this.$search_ele.length){
this.has_search = true;
this.searchFn = this.buildSearchFn(opts.fields);
bindSearchEvent(opts.ele, opts.timeout || 0, this);
unbindSearchEvent(opts.ele, this.searchHandler);
this.searchHandler = bindSearchEvent(opts.ele, opts.timeout || 0, this);
}
};

Expand Down