TypeError:$(...).autocomplete不是一个函数 [英] TypeError: $(...).autocomplete is not a function
本文介绍了TypeError:$(...).autocomplete不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Drupal模块中使用以下代码遇到了以上错误.
I am getting the above error using the following code inside a Drupal module.
jQuery(document).ready(function($) {
$("#search_text").autocomplete({
source:results,
minLength:2,
position: { offset:'-30 0' },
select: function(event, ui ) {
goTo(ui.item.value);
return false;
}
});
});
Jquery肯定已加载,并且我尝试为$使用其他变量-任何想法还有什么问题?
Jquery is definitely loaded, and I have tried using a different variable for $ - any ideas what else might be the problem?
(编辑)Drupal的自动完成答案:
(Edit) Drupal specific answer for autocomplete:
drupal_add_library('system', 'ui.autocomplete');
推荐答案
您错过了jQuery UI库.使用Jquery UI的CDN或在本地使用,然后从 Jquery Ui
you missed jquery ui library. Use CDN of Jquery UI or if you want it locally then download the file from Jquery Ui
<link href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" rel="Stylesheet"></link>
<script src="YourJquery source path"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" ></script>
这篇关于TypeError:$(...).autocomplete不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文