I\'m using jQuery\'s autocomplete in a relatively simple way:
$(document).ready(function() {
var data = [ {text: \"Choice 1\"},
{text: \"Ch
this is the only thing that works for me. List shows everytime and closes upon selection:
$("#example")
.autocomplete(...)
.focus(function()
{
var self = this;
window.setTimeout(function()
{
if (self.value.length == 0)
$(self).autocomplete('search', '');
});
})
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.
You must set minLength
to zero in order to make this work! Here is the working example.
$( "#dropdownlist" ).autocomplete({
source: availableTags,
minLength: 0
}).focus(function() {
$(this).autocomplete('search', $(this).val())
});
});
try this:
$('#autocomplete').focus(function(){
$(this).val('');
$(this).keydown();
});
and minLength set to 0
works every time :)
I can't see an obvious way to do that in the docs, but you try triggering the focus (or click) event on the autocomplete enabled textbox:
$('#myButton').click(function() {
$('#autocomplete').trigger("focus"); //or "click", at least one should work
});
I could not get the $("#example").autocomplete( "search", "" );
part to work, only once I changed my search with a character that exists in my source it work. So I then used e.g. $("#example").autocomplete( "search", "a" );
.