I'm using jQuery's autocomplete in a relatively simple way:
$(document).ready(function() {
var data = [ {text: "Choice 1"},
{text: "Choice 2"},
{text: "Choice 3"} ]
$("#example").autocomplete(data, {
matchContains: true,
minChars: 0,
formatItem: function(item)
{ return item.text; }
}
);
});
How do I add an onclick event (like a button or a link) that will display all the available choices for the autocomplete? Basically I'm looking to make a hybrid of an autocomplete and a select/dropdown element.
Thanks!
You can trigger this event to show all of the options:
$("#example").autocomplete( "search", "" );
Or see the example in the link below. Looks like exactly what you want to do.
http://jqueryui.com/demos/autocomplete/#combobox
EDIT (from @cnanney)
Note: You must set minLength: 0 in your autocomplete for an empty search string to return all elements.