我有一個表單內的引導模式對話框。表單通過AJAX提交。我想submit
按鈕也駁回模式(否則我結束了剩餘的模式疊加)關閉並提交表單引導程序3
代碼的模式是:
@using (Ajax.BeginForm("SaveConfiguredReport", new AjaxOptions { HttpMethod = "POST", InsertionMode = InsertionMode.Replace, UpdateTargetId = "report-details", OnBegin="preProcessing" }))
{
<div class="modal fade" id="add-filter-dialog" tabindex="-1" role="dialog" aria-labelledby="add-filter-dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4>Add a Filter</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<p>Adding filters allows you to sort what data will be included in the report. These filters will be default for all ongoing usage of this report.</p>
<div id="field-templates"></div>
<input type="hidden" id="field-template-id" name="FieldTemplateID" />
@Html.DropDownList("OperatorID", Model.Operators.Select(x => new SelectListItem { Text = x.Name, Value = x.OperatorID.ToString() }))
<input type="text" name="FilterValue" class="typeahead" id="filter-value" />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success" data-dismiss="modal" name="Command" value="Add">Add Filter</button>
</div>
</div>
</div>
</div>
}
<!-- other code -->
<script>
function preProcessing() {
$('.modal').each(function (index, element) {
$(element).modal('hide');
});
}
</script>
如果我保持data-dismiss
屬性提交按鈕,它將解僱表格但不提交。如果我刪除它,表單將被提交但不會被駁回。任何人都有這個運氣?
編輯
我在AJAX調用中添加了一個預處理器,以便在開始時隱藏所有表單。最後隱藏它們不起作用,因爲表單正在替換模式而不是疊加。這是一個解決方法,直到建議一個合適的解決方案
你找到一個更好的解決辦法? – mayu