在jQuery UI的自动完成,在那里做了`response`函数的实现?在那里、函数、自动完成、jQuery

2023-09-10 21:54:06 作者:碧水佳人

我是pretty的新的JS和jQuery的。在我的工作中,我遇到了从jQuery UI自动完成构件,我不完全了解一个jQuery code。我对这个code,它们分为几个职位(如建议在的的元后)一两个问题。此外,对不起,如果我的英语是太可怕了,我做我的最好的。 :)

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. :)

下面是code: http://pastebin.com/NyG48Yb9

我做什么,明白了:

自动完成函数操作的一些输入,在我们的情况 - #searchBox 。该函数得到的参数重新$ P $对象psents列表的行为,当用户键入到 #searchBox 。 的对象有一个名为键描述,提供了列表中的资源。 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.

我不明白#1: 在源的值键是一个回调函数,有两个参数:要求响应。按照 jQuery UI的自动完成API文档,第二个参数是:

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:

一个响应回调

,这意味着它是一个函数。现在,根据,大约回调函数教程(是啊,我做了一些研究:D)有一个函数A和函数B.函数A获得一个parmeter包含引用到被指定为函数B的时候,我们调用一个函数的函数的变量,并执行函数B在功能上的范围。

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.

在我的code,函数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?

非常感谢你。 :)

我的其他问题:In jQuery UI的自动完成,哪些数据源可以了`source`键保持?

推荐答案

响应的实施是present jQuery中,ui.js。它的内部功能。要知道它的实现,你必须下载uncom pressed的jQuery ui.js,将不得不找到自动完成相关code。

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.