This problem is similar to what is described in Execute Javascript inside a partial view in ASP.NET MVC
The below piece of code in index.cshtml is working fine...
<label for="locationOfSearch"> in :</label> @Html.TextBox("locationOfSearch")
<input type="submit" value="Search" style="background-color:Green"/>
@section JavaScript {
<script type="text/javascript">
$(document).ready(function () {
$("#locationOfSearch").autocomplete({
source: '@Url.Action("AutocompleteAsyncLocations")'
})
});
</script>
}
But when I copy and paste the above code and the respective script files to a another view and then in index.cshtml if I call Html.Partial(new view name), Autocomplete is not working...
Kindly let me know how I solve it without much modification...
See Question&Answers more detail:os