I am trying to conditionally change a link URL whenever someone enters a value in a JQuery autocomplete search field, however, using the following code I cannot for some reason either register the change event or even bind a handler:
$("#protocol-name").autocomplete({
source: protocol_names,
}).bind( "autocompletechange", function(){
alterURL();
}).focus(function() {
$(this).select();
$(this).autocomplete('search');
});
Additionally, $("#procotol-name").change() registers nothing either, where protocol-name represents an input field.
Try to do like this:
$( ".selector" ).autocomplete({
change: function(event, ui) { ... }
});
In fact change
event is fired, but only after input element has lost its focus. You can check it yourself.
UPD: this behaviour is inconsistent across browsers, see http://bugs.jqueryui.com/ticket/8878
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