简单的 jQuery 自动完成示例 ASP.NET 应用程序中不起作用
simple jQuery autocomplete example not working in ASP.NET Application
这个线程与我以前的线程有关(使用JavaScript和jQuery的强制建议机制(ASP.NET MVC项目))。但是我遇到的问题太大了,无法将其放在那里。
我正在尝试使用简单的jQuery自动完成示例(http://jqueryui.com/autocomplete/)在我的 ASP.NET NVC 4 Web应用程序中工作。我试过这个:
@model PoliticiOnline.DTO.Question
@{
ViewBag.Title = "Stel een vraag!";
}
<head>
<link rel="stylesheet" href="~/Content/Questions.css" type="text/css" />
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
@Scripts.Render("~/bundles/jqueryval")
<script>
$(function () {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$("#tags").autocomplete({
source: availableTags
});
});
</script>
</head>
<h2>Stel een vraag!</h2>
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>Vraag</legend>
<div class="general-question">
<div class="editor-label">
@Html.LabelFor(model => model.GeneralQuestion, "Algemene Vraag")
</div>
<div class="editor-field">
@Html.EditorFor(model => model.GeneralQuestion, new{@class = "general-question-edit"})
@Html.ValidationMessageFor(model => model.GeneralQuestion)
</div>
</div>
<div class="geadresseerde-politici">
@Html.Label("Politicus")
@Html.DropDownListFor(model => model.PoliticianId, (SelectList)ViewBag.PolIds)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Explanation, "Extra Uitleg")
</div>
<div class="editor-field">
@Html.TextAreaFor(model => model.Explanation, new{@class = "explanation-textarea-edit"})
@Html.ValidationMessageFor(model => model.Explanation)
</div>
<p>
<input type="submit" value="Indienen!" />
</p>
<label for="tags">Tags: </label>
<input id="tags"/>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
只是自动完成不起作用(我还没有尝试与表单一起发送它,我只是希望自动完成工作)。
当我开始在输入字段中输入时,没有任何反应,但它实际上应该给出建议。
我几乎可以肯定错误:
"Uncaught ReferenceError: Uncaught ReferenceError: jQuery is not defined Uncaught ReferenceError: jQuery is not defined Uncaught ReferenceError: $ is not defined
表示 jQuery 未加载到您的页面上。
从CDN加载jquery或类似的东西:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
尝试使用:
$(document).ready(function () { }
相关文章:
- 借助asp.net验证或java脚本对多个文本进行验证
- 将Javascript数组发送到控制器ASP.NET MVC
- ASP.NET通过单击JavaScript按钮触发c#事件
- 文本框不是从Javascript/Asp.net中的对话框中打印出来的
- 从javascript调用asp.net codebehind函数
- 使用javascript的Asp.net内容占位符
- 获取ASP.NET Ajax Timer状态
- ASP.NET网络摄像头显示
- 如何在只能有一个asp.net表单的主页上从asp.net页面中的javascript中获取值
- 如何将乳胶配方奶粉图像保存到Asp.net中的文件夹中
- asp.net,包括iss上的javascript slow
- 选择不在GridView-ASP.NET中激发
- 什么'是在asp.net MVC中将本地化的resources.resx文件转换为javascript文件的有效
- 使用ASP.NET将谷歌地图添加到项目中,并从数据库中检索位置
- 有什么“;错误的”;将javascript放在asp.net表单上,而不是放在单独的文件中
- 将Javascript日期转换为ASP.NET日期格式
- C#asp.net mvc Set CheckBoxFor已检查的具有Model Value的属性
- 在asp.net中确认是或否消息
- ASP.NET MVC 3-在ajax调用后,重定向到新页面或生成页面刷新
- asp.net中的验证工具