I'm using this JQuery autocomplete widget.
How can I make it automatically open the menu when the user clicks in the text box? I want the user to see all the options.
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.
Syntax: $("TagId"). autocomplete({ source : itemList // List of Words. })
The AutoComplete control supports strongly-typed HTML helpers represented by lambda expressions that have model or template passed into the View. So, you can get the selected value from view in the Controller part. To achieve this, create an AutocompleteFor control and bound the dataSource from controller part.
AutoComplete helps you quickly insert functions and arguments while minimizing typing and syntax errors. The AutoComplete menu shows you available options based on context, and you choose what you want to insert into your formula.
You need to trigger the search
event manually and set the minLength
option on the widget to zero:
$("input").autocomplete({
minLength: 0,
/* other options */
}).on("focus", function () {
$(this).autocomplete("search", "");
});
Working example: http://jsfiddle.net/9JmVu/
I think I got it actually. If you set minLength to 0, and then trigger a search for "", it opens the menu.
$(inputSelector).autocomplete(
{
source: this.validConstructCodes,
minLength: 0,
autoFocus: true,
autoSelect: true
});
$(inputSelector).focus(function(event) {
$(this).autocomplete( "search" , "" );
});
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