0
  1. I have include the jquery.unobtrusive-ajax.min.js file in my _Layout.cshtml file. THIS IS THE ONLY PLACE THIS FILE IS REFERENCED.
  2. I have a partial view that uses Ajax.Beginform()
  3. 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.

Community
  • 1
  • 1
gilpach
  • 1,367
  • 3
  • 16
  • 34
  • [Here](http://stackoverflow.com/questions/23895918/mvc5-ajax-beginform-and-the-correct-scripts-load-order) are the scripts you need for Ajax.BeginForm. Show us some code otherwise we're just guessing about what the problem could be. What's the view and rendered html look like? – Jasen Jun 16 '14 at 23:52
  • double check that unobtrusive-ajax.js may be included also in the main layout and also in the view in which ajax.beginform is – Ehsan Sajjad Jun 17 '14 at 04:21
  • Elisan, no, it is not in the view. – gilpach Jun 17 '14 at 13:53

0 Answers0