模态表单多次提交

时间:2013-04-12 12:22:04

标签: ajax asp.net-mvc twitter-bootstrap

我的引导模式多次提交,似乎是模态打开的次数。

代码

<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() {
    $("#SkillModalWindow").modal("hide");
}
</script>

@using (Ajax.BeginForm("Save", "SkillGroup", null, new AjaxOptions
{
    HttpMethod = "Post",
    OnSuccess = "CloseModal"
},
new { id = "CreateSkillGroups" }))
{
@Html.ValidationSummary(true)
@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>
<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>
</div>
}

任何想法?

1 个答案:

答案 0 :(得分:2)

您只是隐藏模态,而不是重置它。发布后需要重置数据。

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