jquery自动完成。源不是一个函数错误。

时间:2022-11-05 12:20:53

I've implemented autocomplete on an input field, but the box does not show up and firebug returns "this.source is not a function". I've used autocomplete on other fields of the same page without any problems. (two textarea's).

我在一个输入字段上实现了autocomplete,但是这个框没有显示,firebug返回“this”。来源不是一个函数。我在相同页面的其他字段上使用了autocomplete,没有任何问题。(两个文本区域)。

I'm using the following code to debug, same effect if I run from script file or Firebug command line.

我正在使用以下代码进行调试,如果我从脚本文件或Firebug命令行运行,效果也是一样的。

var fakedata = ['test1','test2','test3','test4','ietsanders'];
$("#omschrijving").autocomplete(fakedata);

running jquery 1.4.2 and jquery ui 1.8.2, both minified versions.

运行jquery 1.4.2和jquery ui 1.8.2,都是缩小版。

Does anyone have an idea how autocomplete works fine on the textareas but causes this malfunctioning on inputs?

有没有人知道autocomplete是如何在文本区域上正常工作,但在输入上却导致了这种故障?

Error & Stack trace:

错误和堆栈跟踪:

this.source is not a function
http://facturatie.autodealers.nl/dev/resources/js/jquery-ui-1.8.2.custom.min.js
Line 570
close(Object { name="a"})jquery....min.js (regel 570)
close(Object { name="a"}, Object { name="c"})jquery....min.js (regel 570)
response()

4 个解决方案

#1


57  

Answer is that the first parameter of the autocomplete should be an object containing the "source" property. This works

答案是自动完成的第一个参数应该是包含“源”属性的对象。这是

var fakedata = ['test1','test2','test3','test4','ietsanders'];
$("#omschrijving").autocomplete({source:fakedata});

#2


9  

If you were trying to use autocomplete from http://www.devbridge.com/projects/autocomplete/jquery/#demo, it now collides with the autocomplete method in jQuery UI. I had the same problem and later noticed that I could just use the jQuery UI implementation.

如果您试图使用http://www.devbridge.com/projects/autocomplete/jquery/#demo中的autocomplete,那么它现在与jQuery UI中的autocomplete方法发生了冲突。我遇到了同样的问题,后来注意到我可以使用jQuery UI实现。

(NOTE: It appears that this page's documentation is wrong: http://docs.jquery.com/Plugins/Autocomplete#Setup)

(注意:这个页面的文档似乎是错误的:http://docs.jquery.com/Plugins/Autocomplete#Setup)

#3


5  

As Shelton stated, the version from devbridge.com (1.1.3) collides with jQuery UI (1.8.4). Got it working by making sure the devbridge version loads after jQuery UI's version.

正如Shelton所说,来自devbridge.com(1.1.3)的版本与jQuery UI(1.8.4)冲突。通过在jQuery UI的版本后确保devbridge版本的负载,使其工作。

#4


1  

Had similar problem for tagedit/autocomplete. It seems you also want to disable the autocomplete. Setting the source to false avoids these errors.

tagedit/autocomplete也有类似的问题。看起来您还想禁用自动完成。将源设置为false可以避免这些错误。

Solution:

解决方案:

options.autocompleteOptions.source = false;

#1


57  

Answer is that the first parameter of the autocomplete should be an object containing the "source" property. This works

答案是自动完成的第一个参数应该是包含“源”属性的对象。这是

var fakedata = ['test1','test2','test3','test4','ietsanders'];
$("#omschrijving").autocomplete({source:fakedata});

#2


9  

If you were trying to use autocomplete from http://www.devbridge.com/projects/autocomplete/jquery/#demo, it now collides with the autocomplete method in jQuery UI. I had the same problem and later noticed that I could just use the jQuery UI implementation.

如果您试图使用http://www.devbridge.com/projects/autocomplete/jquery/#demo中的autocomplete,那么它现在与jQuery UI中的autocomplete方法发生了冲突。我遇到了同样的问题,后来注意到我可以使用jQuery UI实现。

(NOTE: It appears that this page's documentation is wrong: http://docs.jquery.com/Plugins/Autocomplete#Setup)

(注意:这个页面的文档似乎是错误的:http://docs.jquery.com/Plugins/Autocomplete#Setup)

#3


5  

As Shelton stated, the version from devbridge.com (1.1.3) collides with jQuery UI (1.8.4). Got it working by making sure the devbridge version loads after jQuery UI's version.

正如Shelton所说,来自devbridge.com(1.1.3)的版本与jQuery UI(1.8.4)冲突。通过在jQuery UI的版本后确保devbridge版本的负载,使其工作。

#4


1  

Had similar problem for tagedit/autocomplete. It seems you also want to disable the autocomplete. Setting the source to false avoids these errors.

tagedit/autocomplete也有类似的问题。看起来您还想禁用自动完成。将源设置为false可以避免这些错误。

Solution:

解决方案:

options.autocompleteOptions.source = false;