I’m using a pretty straightforward jQueryUI autocomplete. The only slightly complicated thing is that I have a set list of choices, and the user must enter something from the list. I’m using a JSON array with a label/value hash, displaying the label but seeding a hidden field with the value, so obviously, if the user doesn’t choose something from the list, it’ll fail, as the receiving end expects a valid id in the #word-id field:

The problem was that a user would type something and then hit return, hoping to select the top item, and then nothing happens–nothing would get selected. I tried adding autoFocus, but this fails in a different way: if a user pauses for even a moment while typing, they’ll type over the thing that was autofilled during the pause and end up with gibberish.
What’s the correct way to select the top result on hitting “return”, but not screw up a search in progress?
no comments yet
Be the first to share what you think!
Members
Online

source