2013-04-12 78 views
1

我的引導程序模式多次提交,它似乎是模態已打開的次數。多次提交模態表單

代碼

<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> 
} 

什麼想法?

+0

將腳本包含標籤移動到調用模態的頁面。看起來好像它將每個模態都保存在內存中,直到調用模態的頁面被重新加載。 – Tappies

回答

2

你只是隱藏模式,而不是重置它。您需要在發佈後重置數據。

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