I want to replace a div with a view using @Ajax.actionLink
when I click on that link, but it isn't working.
Here is my link:
<div>
<li> @Ajax.ActionLink("settings","Create","Test",
new AjaxOptions { UpdateTargetId = "components" , InsertionMode = InsertionMode.Replace}
) </li>
</div>
And my target div:
<div id="components">
</div>
I have also included these js file in the layout like that:
<script src="~/Scripts/Controls/jquery-2.0.3.min.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/modernizr-2.5.3.js"></script>
And my action result:
public PartialViewResult Create()
{
return PartialView("Create");
}
For people who installed Microsoft.jQuery.Unobtrusive.Ajax(trough nu-get or not) and want to use it through a bundle, don't forget:
To add the library in your bundleconfig. For example:
bundles.Add(new ScriptBundle("~/bundles/unobtrusive").Include(
"~/Scripts/jquery.unobtrusive*"));
To Render it (mine is rendered in _Layout.cshtml):
@Scripts.Render("~/bundles/unobtrusive")
I know its an old post, but can't hurt to add additional information, I guess.
Believe it or not, I had everything setup correctly, except for one thing:
To install Microsoft jQuery Unobtrusive Ajax, run the following command in the Package Manager Console:
PM> Install-Package Microsoft.jQuery.Unobtrusive.Ajax -Version 3.2.2
Instructions are here: https://www.nuget.org/packages/Microsoft.jQuery.Unobtrusive.Ajax/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With