I\'m trying to replace part of a page with a partial view in ASP.Net MVC 5 (Visual Studio 13) using the following:
Views/Book/Index.cshtml:
1.Install Microsoft.jQuery.Unobtrusive.Ajax using NuGet
2.Add reference to Jquery and Unobtrusive in your _Layout.cshtml
@Scripts.Render("~/bundles/jquery")
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js" >
As an additional note on getting this working. I'm hoping VS 2013 RTM includes this but either way this should get you up and running
install-package Microsoft.jQuery.Ajax.Unobtrusive
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( "~/Scripts/jquery.unobtrusive*", "~/Scripts/jquery.validate*") );
@Scripts.Render("~/bundles/jquery")
or include it in each view you want to use it in
@section Scripts { @Scripts.Render("~/bundles/jqueryval") }
Turns out that jquery.unobtrusive-ajax.js is not included by default. Adding it solved the problem.
I had the same problem drove me nuts with unobtrusive Ajax in MVC with a begin form select list filter getting updated and the list re-displayed as a partial view. I added the first two items below but realized I also needed the last two. Once added the partial view results appeared very nicely.
<script src="~/Scripts/jquery-ui.unobtrusive-2.1.0.js" ></script>
<script src="~/Scripts/jquery-ui.unobtrusive-2.1.0.min.js" ></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.js" ></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js" ></script>