オートコンプリート機能を含む Javascript ファイルを参照しているビューがあります。問題は、このビューで Javascript がまったく機能していないことです。document.ready のアラートでさえ機能しません。別のビューで正確な JavaScript ファイルを使用でき、完全に機能します。次のビューの何が問題なのかわかりません。
見る
@model RunLog.Domain.Entities.ErrorCode
@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Enter a new Error Code</legend>@*<div class="bodyContent">
<span class="leftContent">
@Html.Label("Error ID")
</span><span class="rightContent">
@Html.EditorFor(model => model.ID)
</span>
</div>*@
<div class="bodyContent">
<span class="leftContent">
@Html.Label("Error Description")
</span><span class="rightContent">
@Html.TextBoxFor(model => model.ErrorDescription, new { style = "width: 500px;" })
</span>
</div>
<div class="bodyContent">
<span class="leftContent">
@Html.Label("Parent ID")
</span><span class="rightContent">
@Html.DropDownList("ParentID", String.Empty)
</span>
</div>
<div class="bodyContent">
<span class="leftContent">
@Html.Label("Error Description Complete")
</span><span class="rightContent">
@Html.TextBoxFor(model => model.ErrorDescriptionWithParent, new { style = "width:500px;" })
</span>
</div>
<div class="bodyContent">
<span class="leftContent">
@Html.Label("High Level Error")
</span><span class="rightContent">
@Html.TextBoxFor(model => model.highlevelerror, new { style = "width:500px;" })
</span>
</div>
<div class="bodyContent">
<span class="leftContent">
@Html.Label("Error Number")
</span><span class="rightContent">
@Html.EditorFor(model => model.ErrorNumber)
</span>
</div>
<div class="bodyContent">
<span class="leftContent">
@Html.Label("Track")
</span><span class="rightContent">
@Html.EditorFor(model => model.track)
</span>
</div>
<div class="bodyContent">
<span class="leftContent">
@Html.Label("Lane")
</span><span class="rightContent">
@Html.EditorFor(model => model.lane)
</span>
</div>
<div class="bodyContent">
<span class="leftContent">
@Html.Label("Subsystem")
</span><span class="rightContent">
@Html.EditorFor(model => model.subsystem, new { id = "rootcause" })
</span>
</div>
<div class="bodyContent">
<span class="leftContent">
@Html.Label("Critical")
</span><span class="rightContent">
@Html.EditorFor(model => model.critical)
</span>
</div>
<div class="bodyContent">
<span class="leftContent"></span><span class="rightContent">
<input id="create" class="art-button" type="submit" value="Create" />
</span>
</div>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "List")
</div>
<script type="text/javascript">
var serviceRootCauseUrl = '@Url.Action("FindRootCause", "ServiceEntry")';
</script>
<script src="@Url.Content("~/Scripts/rootcause.js")" type="text/javascript"></script>
ジャバスクリプトファイル
$(document).ready(function () {
$("#rootcause").autocomplete({
source: function (request, response) {
$.ajax({
url: serviceRootCauseUrl, type: "POST", dataType: "json",
minLength: 0,
data: { searchText: request.term, maxResult: 100 },
success: function (data) {
response($.map(data, function (item) {
return { label: item.FullName, value: item.RootCauseName, id: item.ID }
}))
}
})
},
select: function (event, ui) {
// $("#rootcause").text(selecteditem.text);
// alert(ui.item ? ("You picked '" + ui.item.label + "' with an ID of " + ui.item.id)
// : "Nothing selected, input was " + this.value);
}
});
});
レイアウトファイル
<title>@ViewBag.Title</title>
<link rel="stylesheet" href="@Url.Content("~/style.css")" type="text/css" media="screen" />
<!--[if IE 6]><link rel="stylesheet" href="@Url.Content("~/style.ie6.css")" type="text/css" media="screen" /><![endif]-->
<!--[if IE 7]><link rel="stylesheet" href="@Url.Content("~/style.ie7.css")" type="text/css" media="screen" /><![endif]-->
<link href="@Url.Content("~/Content/css/Site.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/css/main.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/css/Content.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/base/jquery.ui.core.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/base/jquery.ui.tabs.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/base/jquery.ui.datepicker.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/base/jquery.ui.theme.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/jquery.treeview.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/jquery-ui-timepicker-addon.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/base/jquery.ui.dialog.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.8.3.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.treeview.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.cookie.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/scrolltable.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/grid.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/datetime.js")" type="text/javascript"></script>