Modal form submitting multiple times

By : Tappies

My bootstrap modal is submitting multiple times, it appears to be for the amount of times the modal has been opened.


<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>

<script type="text/javascript">
// Close Modal when done.
function CloseModal() {

@using (Ajax.BeginForm("Save", "SkillGroup", null, new AjaxOptions
    HttpMethod = "Post",
    OnSuccess = "CloseModal"
new { id = "CreateSkillGroups" }))
@Html.Hidden("JobRoleId", (int)ViewBag.JobRoleID)

<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Add New Skills to Job Role</h3>
<div class="modal-body" id="CreateModal">@Html.Partial("_Create")</div>
<div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    <button type="submit" class="btn btn-primary">Save</button>

Any Ideas?

By : Tappies


You are just hiding the modal, not resetting it. You need to reset the data after you post.

$('#SkillModalWindow').data('modal', null);

This video can help you solving your question :)
By: admin