问题
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 someinput
, 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