Reputation: 4342
I am using jQuery UI 1.10.2 and I would like to manually highlight/focus an item in the list. Basically, I am trying to achieve a HTML select-like behavior:
I can successfully open the suggestion list on input focus and not filter the result list, but I am having a bit of hard time figuring out how to manually highlight/focus the selected element when autocomplete suggestion list is opened and while typing - I am able to find the matching item, but don't know how to "activate" it.
I have tried this:
open: function() {
// Find the selected menu item...
var $menuEl = ...
$(this).data("uiAutocomplete").menu.focus(new $.Event("mouseover"), $menuEl );
}
But it doesn't seem to work.
Upvotes: 2
Views: 1111
Reputation: 4342
It seems that passing null
instead of an event makes it work:
$(this).data("uiAutocomplete").menu.focus(null, $menuEl );
FWIW: I created the Event because an older version of jQuery UI Menu required it. It seems that the UI Menu has changed considerably since then.
Upvotes: 1