在脚本部分,我得到Uncaught Type Error:Undefined不是函数JavaScript错误。可能有什么问题?我检查了.js文件是否已被调用,一切都井然有序。
@model Crux.Models.Question
@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="~/Content/jquery.tagit.css" rel="stylesheet" />
<script src="~/Scripts/jquery-2.1.1.min.js"></script>
<script src="~/Scripts/jquery-ui.js"></script>
<script src="~/Scripts/tag-it.js"></script>
<link href="~/Content/jquery-ui.min.css" rel="stylesheet" />
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Question</h4>
<hr />
@Html.ValidationSummary(true)
<div class="form-group">
@Html.LabelFor(model => model.question, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.question)
@Html.ValidationMessageFor(model => model.question)
</div>
</div>
<div class="form-group">
<label for="hashtags" class="control-label col-md-2">Tags</label>
<div class="col-md-10">
<input id="hashtags" name="hashtags" class="form-control">
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#hashtags").tagit({
allowSpaces: false,
singleField: true,
singleFieldNode: $('#hashtags'),
availableTags: ["c++", "java", "php", "javascript", "ruby", "python", "c"]
});
});
</script>
它在线提供错误:$("#hashtags").tagit({
答案 0 :(得分:0)
我通过加载它三次不同来冲突jQuery。来自bundle和页面本身。删除所有链接,最后工作。