javascriptjqueryjquery-uiautocompletejquery-autocomplete

JQuery UI Autocomplete - Have the menu open when user clicks in the text box


I'm using this JQuery autocomplete widget.

How can I make it automatically open the menu when the user clicks in the text box? I want the user to see all the options.


Solution

  • You need to trigger the search event manually and set the minLength option on the widget to zero:

    $("input").autocomplete({
        minLength: 0,
        /* other options */
    }).on("focus", function () {
        $(this).autocomplete("search", "");
    });
    

    Working example: http://jsfiddle.net/9JmVu/