问题
I need to show user all autocomplete choices, no matter what text he already wrote in the field? Maybe i need some other plugin?
$('#addressSearch').autocomplete("search", "");
That doesn't work.
回答1:
There are two scenarios:
You're using a local data source. This is easy to accomplish in that case:
var src = ['JavaScript', 'C++', 'C#', 'Java', 'COBOL']; $("#auto").autocomplete({ source: function (request, response) { response(src); } });
You're using a remote data source.
$("#auto").autocomplete({ source: function (request, response) { // Make AJAX call, but don't filter the results on the server. $.get("/foo", function (results) { response(results); }); } });
Either way you need to pass a function to the source
argument and avoid filtering the results.
Here's an example with a local data source: http://jsfiddle.net/andrewwhitaker/e9t5Y/
回答2:
You can set the minLength option to 0, then it should work.
来源:https://stackoverflow.com/questions/7526354/jquery-ui-autocomplete-without-filter