0

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

I noticed the question

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

I have the same question and the I get the same problems with the solution.

Basically, I'm trying to force the jquery autocomplete UI to execute on focus and not require the user to press any key or enter any value.

thanks

Community
  • 1
  • 1
David
  • 1,863
  • 2
  • 14
  • 12

1 Answers1

1

What version of jQueryUI are you using? According to the documentation for autocomplete, the way you referenced should work:

("search" method documentation)

...If no value argument is specified, the current input's value is used. Can be called with an empty string and minLength: 0 to display all items.

I've posted an example here that works for me in FF/Chrome: http://jsfiddle.net/andrewwhitaker/B38Hj/. Let me know if you see any weird behavior.

$("input").focus(function() {
    $(this).autocomplete("search");
});

The example uses jQuery UI 1.8.5 and jQuery 1.4.4.

Andrew Whitaker
  • 124,656
  • 32
  • 289
  • 307
  • Thanks it worked. I had tried
     $("#input").focus(function() {
        if ($(this).val().length == 0) {
            $(this).autocomplete("search");
        }
    });    But thatdidn't work well. So THANKS AGAIN!!!
    – David Dec 21 '10 at 15:12