Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery UI Autocomplete autoFocus not working

I am using jQuery UI autocomplete and trying to implement the autoFocus option.

The documentation states the following: If set to true the first item will be automatically focused.

I created a basic example and cannot get to work. I must be missing something obvious. See here: http://jsfiddle.net/9bQJX/

$("#autocomplete").autocomplete({
    source: [
        "ActionScript",
        "AppleScript",
        "Asp",
        "BASIC",
        "C",
        "C++",
        "Clojure",
        "COBOL",
        "ColdFusion",
        "Erlang",
        "Fortran",
        "Groovy",
        "Haskell",
        "Java",
        "JavaScript",
        "Lisp",
        "Perl",
        "PHP",
        "Python",
        "Ruby",
        "Scala",
        "Scheme"
    ],
    autoFocus: true
});
like image 817
Nicolo77 Avatar asked Nov 23 '11 21:11

Nicolo77


1 Answers

You're using an old version of jQueryUI (1.8.9). The option works fine with 1.8.16. In fact, according to the changelog, the autoFocus option was added in 1.8.11, so you should be good with any version >= 1.8.11.

See an updated example using 1.8.16: http://jsfiddle.net/Bqujj/

like image 139
Andrew Whitaker Avatar answered Nov 07 '22 19:11

Andrew Whitaker