jQuery-Autocomplete
jQuery-Autocomplete copied to clipboard
onSelect triggers when clicking the input field
It's strange behaviour that when a user selects the input field when a value has been selected already, the onSelect event triggers. In other words:
- Type in field
- Select suggestion
- Click outside field
- Click inside field
- onSelect is triggered -- even though nothing has changed. The input field merely got focus.
Adding input.off("focus")
solves the issue, but I think it should be default behaviour.
I can confirm. Workaround worked for us. Thanks
I can't get this solution working. Where i should call this input.off("focus")
? I've tried inside the onSelect callback, but input is not defined. If I try to define it with document.getElementById, it does nothing. Any suggestion?
I think you should use it like this:
onSelect: function(suggestion) { $(this).off("focus"); },
Didn't notice any side-effects for workaround so far. Can anyone think of anything probably going wrong?
@diegoflag Look at solution: https://github.com/devbridge/jQuery-Autocomplete/issues/498
Set triggerSelectOnValidInput
to false on the autocomplete options?