0

_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" />

私のモデル

@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>

}

ビュー内のスクリプト

 <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 });
});

エラーは TypeError: $("#Name").autocomplete は関数ではありません

4

1 に答える 1

0

エラーを解決し、スクリプトを別の領域に配置したので、

 @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" />
 }
于 2012-09-10T21:13:12.163 に答える