[英].autocomplete is not a function MVC4
_Layout.cshtml _Layout.cshtml
<script src = "@Url.Content("~/Scripts/jquery-1.7.2.min.js")" type="text/javascript"></script>
<script src = "@Url.Content("~/Scripts/jquery-ui-1.8.23.custom.min.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Content/smoothness/jquery-ui-1.8.23.custom.css")" rel="stylesheet" type="text/css" />
my model 我的模特
@using (Html.BeginForm()){<fieldset>
<legend>Person Search</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
</div>
<p>
<input type="submit" value="Search" />
@*@ko.Html.Button("Search", "SearchPerson", "Person")*@
</p>
} }
scripts in the view 视图中的脚本
<script src = "@Url.Content("~/Scripts/jquery.autocomplete.js")" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#Name").autocomplete('@Url.Action("PersonNameAutocomplete", "Person")', { minChars: 3 });
});
Error is TypeError: $("#Name").autocomplete is not a function 错误是TypeError:$(“#Name”)。autocomplete不是函数
I solved the error and was put scripts in another area, so 我解决了错误,并将脚本放在了另一个区域,所以
@section Scripts
{
@Scripts.Render("~/bundles/jqueryval")
<script src = "@Url.Content("~/Scripts/jquery-1.7.2.min.js")" type="text/javascript"></script>
<script src = "@Url.Content("~/Scripts/jquery-ui-1.8.23.custom.min.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Content/smoothness/jquery-ui-1.8.23.custom.css")" rel="stylesheet" type="text/css" />
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.