Search code examples
jqueryjquery-autocomplete

How to get jQuery Autocomplete to pop up on field focus?


Possible Duplicate:
jQuery autocomplete UI- I'd like it to start the search onfocus without the user having to type anything

jQuery UI Autocomplete

I want the options to appear as soon as my input is focused. Is there a setting for that? I tried setting minLength to 0, but it doesn't work... it still waits for a keypress.


Solution

  • $("#yourField").bind('focus', function(){ $(this).autocomplete("search"); } );
    

    Here a jsfiddle: http://jsfiddle.net/fpHf4/2/ Updated one (for IE): http://jsfiddle.net/q9ERL/4/

    As enlighted by @HoldOffHunger you must also set minLength to 0