delayed keypress event 300ms
This commit is contained in:
parent
9b7cb585e3
commit
4db26a7d66
2 changed files with 24 additions and 13 deletions
|
@ -34,8 +34,8 @@
|
|||
$("<p/>").addClass("formTableFilter").append(label).append(input).insertBefore(this);
|
||||
|
||||
// Bind filtering function
|
||||
$("#" + id).keyup(function (e) {
|
||||
var words = this.value.toLowerCase().split(" ");
|
||||
$("#" + id).delayBind("keyup", function (e) {
|
||||
var words = $(this).val().toLowerCase().split(" ");
|
||||
$("#" + tgt + " tbody tr").each(function () {
|
||||
var s = $(this).html().toLowerCase().replace(/<.+?>/g, "").replace(/\s+/g, " ");
|
||||
var state = 0;
|
||||
|
@ -47,7 +47,7 @@
|
|||
});
|
||||
state ? $(this).hide() : $(this).show();
|
||||
});
|
||||
});
|
||||
}, 300);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
@ -57,4 +57,23 @@
|
|||
labelText: "Keyword(s): ",
|
||||
size: 32
|
||||
};
|
||||
|
||||
$.fn.delayBind = function (type, data, func, timeout) {
|
||||
if ($.isFunction(data)) {
|
||||
timeout = func;
|
||||
func = data;
|
||||
data = undefined;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
var wait = null;
|
||||
var handler = function (e) {
|
||||
clearTimeout(wait);
|
||||
wait = setTimeout(function() {
|
||||
func.apply(self, [$.extend({}, e)]);
|
||||
}, timeout);
|
||||
};
|
||||
|
||||
return this.bind(type, data, handler);
|
||||
};
|
||||
})(jQuery);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue