这是我的场景。
我使用它的 ajax 功能调用 jqModal,在模式对话框中显示一个表单。用户填写一些信息并提交返回一些 html 作为响应的表单。
生成的 html 显示在 jqModal div 中。用户然后单击关闭以关闭模式对话框。
到目前为止,这一切都正常工作。
相反,我想要做的是关闭提交对话框并使用来自服务器的响应更新 div。
调用代码:
<script type="text/javascript">
$(document).ready(function () {
$('#jqmWindowContainer').jqm({
modal: true,
ajax: '.... url to display my form ...',
onHide: myAddClose,
ajaxText: 'Loading',
toTop: true,
});
function myAddClose(hash) {
hash.w.fadeOut('300', function () { hash.o.remove(); });
}
});
</script>
调用页面的标记。单击“保存此搜索”会触发对话框。
<a href="#" class="jqModal">Save this search</a>
<span id="jqmWindowContainer" class="jqmWindow"></span>
显示的表格:
<div class="jqmPopupForm" id="jqmPopupForm">
<div id="loadingMessage" style="display: none;">
Saving...
</div>
<% using (Ajax.BeginForm("Save", "AssetSearch",
new AjaxOptions()
{ HttpMethod = "Post", InsertionMode = InsertionMode.Replace,
UpdateTargetId = "jqmPopupForm",
LoadingElementId = "loadingMessage"
}))
{%>
.... some html input elements go here ...
<input type="submit" value="Save Search" />
<a class="jqmClose" href="#">Cancel</a>
<%
}%>
</div>
现在,整个 jqmPopupForm div 正在被表单提交的结果所取代。
如何关闭对话框并更新页面上的 div 而不是让用户关闭对话框?