jQuery-Autocomplete icon indicating copy to clipboard operation
jQuery-Autocomplete copied to clipboard

onSelect fires on clicking input box

Open oshihirii opened this issue 7 years ago • 6 comments

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]

oshihirii avatar Sep 02 '17 04:09 oshihirii

Same issue here :/

benoitongit avatar Sep 06 '17 19:09 benoitongit

@benoitongit - fyi i made highly commented demo here, it may help! https://codepen.io/oshihirii/pen/EvMjZm

oshihirii avatar Sep 06 '17 19:09 oshihirii

Thanks :) Looks like adding triggerSelectOnValidInput: false as option fix this issue

benoitongit avatar Sep 06 '17 19:09 benoitongit

Cool 👍

oshihirii avatar Sep 06 '17 20:09 oshihirii

Thanks, had the same issue.

geekonthepc avatar Sep 04 '19 10:09 geekonthepc

And a year later, also thanks, this was bugging me and glad to see that option.

tgice avatar Oct 26 '20 21:10 tgice