I am getting the above error using the following code inside a Drupal module.
我在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 is definitely loaded, and I have tried using a different variable for $ - any ideas what else might be the problem?
Jquery肯定是加载的,我尝试使用另一个变量$ - 任何想法还有什么可能是问题?
(Edit) Drupal specific answer for autocomplete:
(编辑)自动完成的Drupal特定答案:
drupal_add_library('system', 'ui.autocomplete');
3 个解决方案
#1
54
you missed jquery ui library. Use CDN of Jquery UI or if you want it locally then download the file from Jquery Ui
你错过了jquery ui图书馆。使用Jquery UI的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>
#2
3
Simple solution: The sequence is really matter while including the auto complete libraries:
简单的解决方案:包含自动完成库时,序列非常重要:
<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>
#3
2
In my exprience I added two Jquery libraries in my file.The versions were jquery 1.11.1 and 2.1.Suddenly I took out 2.1 Jquery from my code. Then ran it and was working for me well. After trying out the first answer. please check out your file like I said above.
在我的经验中,我在我的文件中添加了两个Jquery库。版本是jquery 1.11.1和2.1.Suddenly我从我的代码中取出了2.1 Jquery。然后运行它,并为我工作。在尝试第一个答案后。请检查你的文件,就像我上面说的那样。
#1
54
you missed jquery ui library. Use CDN of Jquery UI or if you want it locally then download the file from Jquery Ui
你错过了jquery ui图书馆。使用Jquery UI的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>
#2
3
Simple solution: The sequence is really matter while including the auto complete libraries:
简单的解决方案:包含自动完成库时,序列非常重要:
<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>
#3
2
In my exprience I added two Jquery libraries in my file.The versions were jquery 1.11.1 and 2.1.Suddenly I took out 2.1 Jquery from my code. Then ran it and was working for me well. After trying out the first answer. please check out your file like I said above.
在我的经验中,我在我的文件中添加了两个Jquery库。版本是jquery 1.11.1和2.1.Suddenly我从我的代码中取出了2.1 Jquery。然后运行它,并为我工作。在尝试第一个答案后。请检查你的文件,就像我上面说的那样。