jQuery-Autocomplete
jQuery-Autocomplete copied to clipboard
onSelect fires on clicking input box
Hello,
I am just testing jQuery-Autocomplete and have set up a simple example from documentation:
var countries = [
{ value: 'Andorra', data: 'AD' },
// ...
{ value: 'Zimbabwe', data: 'ZZ' }
];
$('#autocomplete').autocomplete({
lookup: countries,
onSelect: function (suggestion) {
alert('You selected: ' + suggestion.value + ', ' + suggestion.data);
}
});
The alert fires when selecting the suggestion (which is expected), but then it also fires when clicking on the input box again and gets stuck in a loop of showing the alert.
How can this be avoided?
I am wanting to test more advanced examples to (ajax, templated results, multiple value search etc), but just want to make sure this issue can be resolved before proceeding.
Thank You.
[Am using: https://cdnjs.cloudflare.com/ajax/libs/jquery.devbridge-autocomplete/1.4.2/jquery.autocomplete.min.js]
Same issue here :/
@benoitongit - fyi i made highly commented demo here, it may help! https://codepen.io/oshihirii/pen/EvMjZm
Thanks :)
Looks like adding
triggerSelectOnValidInput: false
as option fix this issue
Cool 👍
Thanks, had the same issue.
And a year later, also thanks, this was bugging me and glad to see that option.