I have this code :
var myList = [ "Avellino", "Enna", "Frosinone" ];
myInput.autocomplete({
source: function(request, response) {
var data = $.grep(myList, function(value) {
return value.substring(0, request.term.length).toLowerCase() == request.term.toLowerCase();
});
response(data);
},
appendTo: "#myDiv"
});
and I'd like, when I click on the input box, show the list of all elements (with the same autocomplete box for choose value) of myList
.
I suppose I need a third part handler, like :
myInput.focus(function () {
});
but I don't know how to dialogate with the autocomplete. Any ideas/solutions?
@jasonlfunk is halfway there-- You have to call search
on the autocomplete widget upon focus
to get this to work:
var myList = [ "Avellino", "Enna", "Frosinone" ];
$('#myInput').autocomplete({
minLength: 0,
source: function(request, response) {
var data = $.grep(myList, function(value) {
return value.substring(0, request.term.length).toLowerCase() == request.term.toLowerCase();
});
response(data);
}
}).focus(function () {
$(this).autocomplete("search", "");
});
Example: http://jsfiddle.net/BRDBd/
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