I'm using jQuery UI Autocomplete with some AJAX (the data isn't pulled until after they stop typing). I would like to make it so once the data is found, Autocomplete will then pop-up as a search result. This works, however only when I start typing again (the dropdown doesn't trigger until I type because it's not initialized until after I stop typing).
My code:
var availableTags = [
"Perl",
"PHP",
"Python",
"Ruby"
];
$('input#mainSearchBox').autocomplete({
source: availableTags,
minLength: 0
});
$('input#mainSearchBox').data('autocomplete').menu.active;
The last part was an attempt to activate autocomplete, but it fails.
The jQuery UI Autocomplete change event is used to trigger when the search field is blurred and the value has changed. Syntax: Initialize the autocomplete with the change callback specified: $( ".
In the process of searching a specific value, the jQuery UI autocomplete selection feature provides the user with some string suggestions for the input area which effectively saves time. The autocomplete select action is triggered when the user selects one of the options from the pre-populated list.
Advertisements. Auto completion is a mechanism frequently used in modern websites to provide the user with a list of suggestions for the beginning of the word, which he/she has typed in a text box. The user can then select an item from the list, which will be displayed in the input field.
The search method should do the trick:
$('input#mainSearchBox').autocomplete("search");
Fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With