I am tryin to use click and blur at the same time.
I got a input type="text". This input opens an autocomplete div. Now I trace a click event on the div to set the value. This works smoothly. But when I now add a blur event on the input, they fire at the same time, so when i click the div it also fires the blur of the input.
What i wanna do is to check, if the click even was fired, before the blur fires and in case that the click event was fired before, that it stops the blur.
I tried to use a contoller varible that I set to true and false, but the problem is, that the blur always fires first, so there is no time for the click event to change the controller variable in time.
I don't think that it totally helps me solvin this problem.
Maybe I should describe it in a different way:
I have this autocomplete input (for companies); and when I start enterin smth the autocomplete div is showed. So when I click on the div, the selected value has to be "taken". So this is the click event (which "overwrites" the input with a span and the selected value). But on the other hand it can happen, that the value of the input doesn't match the items in the database. But still has to be accepted. therefore i need this blur event. So when the user "leaves" the input, the input shall again be "overwritten" by a span and this time, the value of the input.
I hope it is possible to understand what i mean :D haha
Okay, so ignoring the comments I have placed into the code, isn't it just a matter of within the focusout event of #item1 (the input text box) you leave whatever value is there, and on a click of #item2 (the autocomplete div) you place whatever has been selected into #item1?
In fact, why do you require a blur event at all? What processing is occuring on a blur event? I think I had mistakenly assumed that you wanted the autocomplete div to appear on blur, but if this is just a text field then you can just replace the function I have for #item1 with a 'keydown' instead of a 'focusin' to show the autocomplete div. Or is this what you have already?! I'm a bit confused! Maybe if you add the code you have already it will become a bit more clearer.