I have an input and on blur I want to save the value.
The problem is that I have autocomplete on and when the users clicks on a suggestion from the autocomplete list the blur is triggered.
For example: the users enters “iP” in the input and then clicks “iPhone” from the autocomplete list. In this caste both “iP” and “iPhone” values are stored (“iP” store triggered by blur and “iPhone” store triggered by autocomplete click).
I was thinking about checking if the blur action was triggered by a click on the autocomplete list.
$('input').blur(function(e){
if(e.IsClickOnAutocomplete)
return;
else save_value;
});
So, how can I check in which way the blur was triggered?
EDIT
Here, a jsFiddle that shows something simillar to my problem http://jsfiddle.net/mkp8m/1
Ok, after making clear what
autocompleteyou mean, here is the solution.Use
changeevent of autocomplete plugin:DEMO: http://jsfiddle.net/mkp8m/2/