0x800a01b6 - JavaScript 运行时错误:对象不支持属性或方法“自动完成”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24317993/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'autocomplete'
提问by john Gu
I have the following script inside my asp.net mvc 5 web project:-
我的 asp.net mvc 5 web 项目中有以下脚本:-
$("input[data-autocomplete-source]").each(function () {
var target = $(this);
target.autocomplete({ source: target.attr("data-autocomplete-source"), minLength: 1, delay: 1000 });
});
but i am getting the following exception :-
但我收到以下异常:-
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'autocomplete'
so can anyone advice what might be causing this error ? Thank
那么任何人都可以建议可能导致此错误的原因吗?感谢
EditInside my _layout view i have the following:-
在我的 _layout 视图中编辑我有以下内容:-
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
and on the view that is raising the error i define the following:-
并在引发错误的观点上,我定义了以下内容:-
@section Scripts{
@Scripts.Render("~/bundles/jqueryval")
<script src="~/Scripts/Custome.js"></script>}
where the cusotm.js contains my above auto complete code. i have noted another problem is that i have Ajax.BeginForm on my view, but it is working as normal form , and it is not generating Ajax requests, although i am loading the ~/bundles/jqueryval ? can you adivce ?
其中 cusotm.js 包含我上面的自动完成代码。我注意到另一个问题是我有 Ajax.BeginForm 在我的视图中,但它以正常形式工作,并且它不生成 Ajax 请求,尽管我正在加载 ~/bundles/jqueryval ?你能建议吗?
回答by jfriend00
If you don't have the .autocomplete()
method, then that is probably because you don't have the right jQuery plugins loaded that contain that method.
如果您没有该.autocomplete()
方法,那可能是因为您没有加载包含该方法的正确 jQuery 插件。
If you intend to be using the autocomplete method from the jQuery UI set of plugins, then you need to load that library before you can use this method.
如果您打算使用 jQuery UI 插件集中的自动完成方法,那么您需要先加载该库,然后才能使用此方法。