- I have include the jquery.unobtrusive-ajax.min.js file in my _Layout.cshtml file. THIS IS THE ONLY PLACE THIS FILE IS REFERENCED.
- I have a partial view that uses Ajax.Beginform()
- I have a view (non-partial) that also uses Ajax.BeginForm()
The Partial View works as expected, the submit is invoked once. The non-partial View invokes the submission twice.
The only way I could work around this was to remove the ...ajax.min.js file from the _Layout.cshtml file and place it in the partial view. After doing this both the View and Partial view submit only once.
One of the responses here suggests not using the ...ajax.min.js file since Ajax.Beginform() will work without it - but that doesn't seem to jive with all other posts.
Any ideas of the proper usage?
Thanks!
** UPDATE ** This is the configuration that does not work:
Scripts in my _Layout.cshtml file:
<script src="@Url.Content("~/Scripts/kendo/2014.1.528/jquery.min.js")"></script>
<script src="@Url.Content("~/Scripts/kendo/2014.1.528/kendo.all.min.js")"></script>
<script src="@Url.Content("~/Scripts/kendo/2014.1.528/kendo.aspnetmvc.min.js")"></script>
<script src="@Url.Content("~/scripts/kendo.modernizr.custom.js")"></script>
<script src="@Url.Content("~/Scripts/kendo.web.ext.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")"></script>
<script src="@Url.Content("~/Scripts/bootstrap.js")"></script>
And here is the Ajax.BeginForm() in my View:
@using (Ajax.BeginForm(new AjaxOptions { UpdateTargetId = "result", OnSuccess = "OnSuccess" }))
{
...
}
And here is the Ajax.BeginForm() in my partial view:
@using (Ajax.BeginForm("SaveEfficiencyMetrics", "Plan",
new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "result", OnSuccess = "OnSuccess", InsertionMode = InsertionMode.Replace },
new { target = "_self", id = "_SpaceEfficiencyMetrics" }))
{
...
}
Once again, the partial view works, submit is invoked once. however, the main view submit is invoked twice.
I have verified that I am not referencing the script twice.