The Jquery autocomplete (LINK) has an option to turn it off, which looks like this:
$(input).autocomplete({ disabled: true });
I would like it to be turned off because its default settings is to respond on keyup. I much rather have it function on keydown. So I turned it off and I wrote a function with an event keydown like this:
timer = 0;
function func (){
var val = $(input).val();
$(input).autocomplete('search', val);
}
$(input).live('keydown', function(){
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(func, 50000);
$(input).autocomplete( "enable" );
});
It doesn't work...meaning it does not do search after 50000 ms but instead it does the default setting with keyup. What should I change?
Add a keyup event and stop the event propogation.
Add a keydown event and call it like this: $("input").autocomplete('search', 'demo-value');
$(input).autocomplete().keyup(function(event) {
event.stopPropagation();
}).keydown(function() {
$(this).autocomplete('search', $(input).val()); //this or $(input)...
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With