我在一个Drupal模块中使用下面的代码得到了上面的错误。
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肯定是加载了,我已经尝试使用一个不同的变量来表示$-知道还有什么问题吗?
(编辑)自动完成Drupal特定答案:
drupal_add_library('system', 'ui.autocomplete');
您错过了jquery ui库。 使用Jquery UI的CDN,或者如果您需要本地的CDN,则从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>
简单的解决方案:当包含自动完成库时,序列确实很重要:
<link href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" rel="Stylesheet"></link>
<script src='https://cdn.rawgit.com/pguso/jquery-plugin-circliful/master/js/jquery.circliful.min.js'></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" ></script>
在我的实验中,我在我的文件中添加了两个Jquery库,版本分别是jQuery1.11.1和2.1.突然,我从代码中取出了2.1Jquery。 然后经营它,为我工作得很好。 在试了第一个答案之后。 请像我上面说的那样检查你的档案。