Forum Moderators: open

Message Too Old, No Replies

Auto-completion field

Problem with blur and focus and an auto-complete field

         

Twister47

6:09 pm on May 26, 2006 (gmt 0)

10+ Year Member



I'm currently working on a auto-suggestion textfield much like:
[labs.google.com...]

And everything is just fine except, I cannot seem to find a good solution on how to handle clicking.

This is how I would like the page to respond (which is how the google model works):
When a user clicks away from the field (ex: clicks on the body of the page) the suggestion box closes. But when a user clicks on the actual suggestions in the box it remains open.

My problem is that a simple onblur event does not work on the textfield because then it closes when you try to click on a suggestion.

I tried setting a global var that goes on and off when the suggestion box receives focus so that you know if it has focus, but the onblur event that closes the box fires before the onfocus event can mark it has focused.

Any help would be appreciated, thank you

Twister47

6:37 pm on May 26, 2006 (gmt 0)

10+ Year Member



I was able to workaround the problem by simply having it do a setTimeout of 100 ms, which gives the onfocus event enough time to fire.

Just feel like there still should be a less 'hacky' kind of way.