In jQuery UI Autocomplete, where does the `response` function is implemented?

為{幸葍}努か 提交于 2019-12-12 02:09:10

问题


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 #1:
The value of the source key is a callback function that gets two parameters: request and response. According to the jQuery UI Autocomplete API Documentation, the second parameter is:

A response callback

which means that it is a function. Now, according to that tutorial about callback functions (Yeah, I did some research :D) there is a function A and a function B. Function A gets as a parmeter a variable that contains a reference to a function that is specified to be function B when we call function A, and function B is executed in the scope of function A.

In my code, function A is the anonymous function in the source key, and the response is the callback function. But I cannot find any implementation of the response function.

My question:
Where does the response function is implemented? And where can I fine a documentation?

Thank you very much. :)


My other question: In jQuery UI Autocomplete, what data sources can the `source` key hold?


回答1:


The implementation of response is present in jquery-ui.js. Its their internal function. To know its implementation you will have to download uncompressed jquery-ui.js and will have to locate autocomplete related code.



来源:https://stackoverflow.com/questions/32141272/in-jquery-ui-autocomplete-where-does-the-response-function-is-implemented

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