前提 主窗口页面使用Ext,弹出窗口使用Jquery 效果要求:弹出窗口在提交动作执行完毕后自动关闭窗口
具体代码实现 (主页面 Ext 代码)
function displayCurrentTaskForm(taskUUID) {
Ext.Ajax.request({
url : '<%=rootPath%>/displayCurrentTaskForm.action',
params : {
taskInstanceUUID : taskUUID,
username: username
},
success : function(response, options) {
var htmlStr="<iframe src='<%=rootPath%>/view/xxx.jsp?taskInstanceUUID="+taskUUID+"&action=XXX.action' id='frameid' name='frameid' width='100%' height='100%' frameborder='0' scrolling='no'></iframe>";
var dialogHandler = new Ext.Window({
id : 'showWindow',
title : '',
frame : true,
width : 800,
height : 450,
layout : 'fit',
modal : true,
items : [ {
height : 390,
autoScroll : true,
border : false,
name : '',
id : '',
html : htmlStr
} ]
});
dialogHandler.on('close',function(){
/*刷新记录*/
var gridPanel = Ext.getCmp('xxxxxPanel');
gridPanel.getStore().reload();
});
dialogHandler.show();
}
});
}
弹出窗口
var action="<%=request.getParameter("action")%>" ;
var options = {
target: '#MyResult',
url: '<%=rootPath%>/'+action,
type :'post',
beforeSubmit: showRequest,
success: showResponse,
dataType: 'json',
timeout: 3000
};
$(document).ready(
function()
{
$('#diplayTaskForm').submit(function() {
$(this).ajaxSubmit(options);
return false;
});
}
);
function showRequest(formData, jqForm, options) {
return true;
}
function showResponse(responseText, statusText, xhr, $form) {
if (responseText=="success") {
var xShadow=$(".x-shadow", window.parent.document);
var mask=$(".ext-el-mask", window.parent.document);
var p=$('#showWindow', window.parent.document);
mask.remove();
xShadow.remove();
p.remove();
}
}
方法二
在父窗口设一全局变量
var popWindow;
popWindow= new Ext.Window({
id : 'showWindow',
title : '<div align="center" style="bgcolor:blue">Process Start ['+name+']</div>',
width : 600,
frame : true,
height : 450,
layout : 'fit',
modal : true,
items : [ { height : 390,autoScroll : true,border : false,name : '',id : '',items: form1} ]
});
popWindow.show();
function showResponse(responseText, statusText, xhr, $form) {
controlSubmit(false);
if (responseText=="success") {
/*
var xShadow=$(".x-shadow", window.parent.document);
var mask=$(".ext-el-mask", window.parent.document);
var p=$('#showWindow', window.parent.document);
mask.remove();
xShadow.remove();
p.remove();
*/
window.parent.popWindow.close();
}
} else {
alert("Fail "+responseText);
}
}