Stop jQuery autocomplete to filter/search results and populate the entire source array data

好久不见. 提交于 2019-12-25 07:59:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!