jQuery自动完成(1.8.5)——未捕获的类型错误,属性“source”不是函数

时间:2022-11-05 12:16:11

I am attempting to use the jQuery autocomplete widget which I have used previously on earlier versions of jQuery.

我正在尝试使用jQuery自动完成小部件,我在早期jQuery版本中使用过这个小部件。

With the code I'm currently using (and jQuery UI 1.8.5) I am getting the following error when typing a letter in the initialised autocomplete input field:

使用当前使用的代码(以及jQuery UI 1.8.5),在初始化的自动完成输入字段中输入一个字母时,会出现以下错误:

jquery-ui-1.8.5.custom.min.js:320Uncaught TypeError: Property 'source' of object #<an Object> is not a function

The autocomplete code is basically the jQuery example documentation (added to my page with other JS on it):

autocomplete代码基本上是jQuery示例文档(在我的页面中添加了其他JS):

<input type="text" id="example" />
<script type="text/javascript">
    var data = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" ");
    $("#example").autocomplete(data);
</script>

Anyone have any suggestions?

有人有什么建议吗?

Thanks in advance.

提前谢谢。

2 个解决方案

#1


17  

I think that should be:

我认为应该是:

$("#example").autocomplete({ source: data });

#2


2  

It looks like you are trying to call the autocomplete widget in jQuery UI the same way that the deprecated autocomplete jQuery plugin was called. The entire API is different, so take a look at the migration guide, but your example would be

看起来您试图在jQuery UI中调用自动完成小部件,就像调用已弃用的自动完成jQuery插件一样。整个API是不同的,所以看看迁移指南,但是您的例子是。

$("#example").autocomplete({ source: data });

#1


17  

I think that should be:

我认为应该是:

$("#example").autocomplete({ source: data });

#2


2  

It looks like you are trying to call the autocomplete widget in jQuery UI the same way that the deprecated autocomplete jQuery plugin was called. The entire API is different, so take a look at the migration guide, but your example would be

看起来您试图在jQuery UI中调用自动完成小部件,就像调用已弃用的自动完成jQuery插件一样。整个API是不同的,所以看看迁移指南,但是您的例子是。

$("#example").autocomplete({ source: data });