JQuery UI autofocus autofocus not working

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

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

I created a basic example and cannot work. I have to miss 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 }); 
+6
source share
3 answers

The old version of jQueryUI (1.8.9) is used. The option works fine with 1.8.16. In fact, according to the list of changes , the autoFocus option was added in 1.8.11, so you should be fine with any version> = 1.8.11.

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

+6
source

save autoFocus = true before source option. for example as shown below.

 $("#autocomplete").autocomplete({ **autoFocus : true,** source: [ "ActionScript", "AppleScript" ] }) 
0
source

Open the jquery-ui.js file and search for "autocomplete." Change the autofocus to true. eg.

 $.widget ( "ui.autocomplete", { version: "1.12.1", ... ... options: { ... ... autoFocus: true, ... ... 

Configuration screenshot

0
source

Source: https://habr.com/ru/post/902254/


All Articles