问题
Problem:
I am using jQuery autocomplete for input type text.
I do not want to filter/search the results based on input and want to display all the source array values as suggestions. Any idea how to achieve this?
Is there a a method/alternative to just populate an entire array data source as suggestions without searching or flltering?
Tech note:
- I'm actually using an onkeyup/press event in my input[text] which calls an ajax. Upon ajax success the autocomplete is called.
- jQuery v1.10.2
- Query UI v1.11.3
Code sample:
var pr_suggst= new Array();
for(var i=0; i< scnt; i++)
pr_suggst[i]= {value:availableTags[i]['name'], idx:availableTags[i]['id']};
$("#text_inp_id").autocomplete({source: pr_suggst});
Thanks you.
回答1:
try to not filter the contents, so that just make the request.term as empty
source: function( request, response ) {
response( $.ui.autocomplete.filter(
availableTags, "" ) ); // here
},
Example fiddle
来源:https://stackoverflow.com/questions/29028693/stop-jquery-autocomplete-to-filter-search-results-and-populate-the-entire-source