【发布时间】:2017-11-28 02:11:12
【问题描述】:
我目前正在开发一个网络应用程序。 在那里,我创建了一个文本框(与 jquery 自动完成一起使用),当用户单击按钮时会显示该文本框。 然后我想从我的数据库中加载自动完成所需的源。但我目前正在用一些随机值对其进行测试。 当我这样称呼时:
$("#docNameTB").autocomplete({
source: ["Apple", "Banana"]
});
控制台显示:“Uncaught TypeError: $(...).autocomplete is not a function”
这是我的脚本来源:
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
这是我的事件代码:
function nextClicked() {
$("#docNameTB").autocomplete({
source: ["Apple", "Banana"]
});
}
这是我的文本框:
@Html.TextBox("docNameTB", "", new { @class = "form-control", @placeholder="Enter name here" })
这是我的按钮按下代码:
<a class="btn btn-default" id="nextButton" onclick="nextClicked()">Next »</a>
this 问题的解决方案对我不起作用。 我也只使用 google places 脚本源,这不是问题(我已经测试过了):
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=MY_KEY&libraries=places"></script>
为我糟糕的英语和我的格式感到抱歉,这是我的第一个问题。 :) 我希望有人能帮助我! 感谢您的回复!
【问题讨论】:
-
确保您没有在页面中再次加载 jQuery.js,这会清除 jQuery-UI 中包含的所有插件方法
标签: javascript jquery autocomplete