Autocomplete: new option autoFocus, default false. Fixed #7032 - Autocomplete: Add option to automatically highlight the first result

This commit is contained in:
Richard Worth 2011-03-15 05:43:19 -04:00
parent 69ebdf46a5
commit 779df6517d
2 changed files with 6 additions and 0 deletions

View File

@ -4,6 +4,7 @@
var autocomplete_defaults = { var autocomplete_defaults = {
appendTo: "body", appendTo: "body",
autoFocus: false,
delay: 300, delay: 300,
disabled: false, disabled: false,
minLength: 1, minLength: 1,

View File

@ -20,6 +20,7 @@ var requestIndex = 0;
$.widget( "ui.autocomplete", { $.widget( "ui.autocomplete", {
options: { options: {
appendTo: "body", appendTo: "body",
autoFocus: false,
delay: 300, delay: 300,
minLength: 1, minLength: 1,
position: { position: {
@ -359,6 +360,10 @@ $.widget( "ui.autocomplete", {
this.menu.deactivate(); this.menu.deactivate();
this.menu.refresh(); this.menu.refresh();
if ( this.options.autoFocus ) {
this.menu.next( new $.Event("mouseover") );
}
// size and position menu // size and position menu
ul.show(); ul.show();
this._resizeMenu(); this._resizeMenu();