Good Morning,
I have the following code:
$("#close-request-field-clinic").autocomplete({
source: arrayClinic,
delay: 0,
minLength: 0,
isDivider: function( item ) {
return false;
},
focus: function ( event, ui ) {
$('#close-request-field-clinic').val( ui.item.label );
return false;
},
select: function( event, ui ) {
$('#close-request-field-clinic').val( ui.item.label );
if(ui.item.value == -1) {
resetField('#close-request-field-clinic', false);
} else {
successField('#close-request-field-clinic');
setKey(finalValues, 'clinic', ui.item.value);
if(msieversion()) {
$(this).blur();
}
}
checkValidation(fieldCheck,'#close-request-personal-information-next');
return false;
},
change: function( event, ui ) {
alert('change');
if(!ui.item) {
resetField('#close-request-field-clinic', false);
removeKey(finalValues, 'clinic');
}
checkValidation(fieldCheck,'#close-request-personal-information-next');
return false;
}
}).focus(function(){$(this).autocomplete("search", "")});
The majority of this works perfectly, however, it seems that when the field is changed the 'change' event is not always triggered.
When selecting an element from the list, it works fine, however if you delete the values in the box using the backspace (delete) key, and then click off the text box, the change event is only sometimes called. Is there something I'm missing?.. It seems to only not be called when values are deleted manually.
Regards, Josh
This is alternative clean solution
$("#close-request-field-clinic").on("autocompletechange", function(event,ui) {
alert($(this).val());
});
This answer copied from here
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