In jQuery UI Autocomplete, what data sources can the `source` key hold?

大城市里の小女人 提交于 2019-12-11 10:59:14

问题


I am pretty new in JS and in jQuery. In my work I came across a jQuery code from the jQuery UI Autocomplete widget that I do not fully understand. I have a two questions about this code which are separated into several posts (As recommended in that meta post). Also, sorry if my English is horrible, I'm doing my best. :)

Here is the code: http://pastebin.com/NyG48Yb9

What I DO understand:

  • The autocomplete function operates on some input, in our case - the #searchBox. The function get as parameter an object that represents the behavior of the list when the user types into the #searchBox.
  • The object has a key named source which describes the resource that provides the list.

What I DO NOT understand #2:
The value of the source key, in this case - is a callback function that according to the jQuery UI Autocomplete API Documentation, is:

The third variation, a callback, provides the most flexibility and can be used to connect any data source to Autocomplete.

My question
What kind of data source is included in "any data source"? string, Array, Object? A remote resource that provides a JSON using Ajax? Other? Can you give me an example?

Thank you very much. :)


My other question: In jQuery UI Autocomplete, where does the `response` function is implemented?

来源:https://stackoverflow.com/questions/32143422/in-jquery-ui-autocomplete-what-data-sources-can-the-source-key-hold

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