我有一个extjs2表单面板:
var fsf = new Ext.FormPanel({
labelWidth: 75, // label settings here cascade unless overridden
frame:true,
id: 'formPanel',
title: 'Simple Form with FieldSets',
bodyStyle:'padding:5px 5px 0',
width: 550,
items: [{
xtype:'fieldset',
checkboxToggle:true,
title: 'User Information',
autoHeight:true,
defaults: {width: 210},
defaultType: 'textfield',
collapsed: true,
items :[{
fieldLabel: 'First Name',
name: 'first',
allowBlank:false
},{
fieldLabel: 'Last Name',
name: 'last'
},{
fieldLabel: 'Company',
name: 'company'
}, {
fieldLabel: 'Email',
name: 'email',
vtype:'email'
}
]
},{
xtype:'fieldset',
title: 'Phone Number',
collapsible: true,
autoHeight:true,
defaults: {width: 210},
defaultType: 'textfield',
items :[{
fieldLabel: 'Home',
name: 'home',
value: '(888) 555-1212'
},{
fieldLabel: 'Business',
name: 'business'
},{
fieldLabel: 'Mobile',
name: 'mobile'
},{
fieldLabel: 'Fax',
name: 'fax'
}
]
}],
buttons: [{
text: 'Save',
handler: function(){
var form = Ext.getCmp('formPanel').getForm();
if(form.isValid())
form.submit({
waitMsg:'Loading...',
url: 'RepeatSession.jsp',
success: function(form,action) {
//we have to close the window here!!
},
failure: function(form,action){
Ext.MessageBox.alert('Erro',action.result.data.msg);
}
});
}
},{
text: 'Cancel'
}]
});和一个窗口:
win = new Ext.Window(
{
layout: 'fit',
width: 500,
height: 300,
modal: true,
closeAction: 'hide',
items: fsf
});
win.show();正如您所看到的,表单面板作为一个项目位于窗口内。在成功提交表单后,我必须关闭窗口,但我不知道如何访问成功处理程序中的窗口对象。
提交表单成功后如何隐藏窗口?
发布于 2012-02-27 03:29:59
在创建窗体之前,只需保存对窗口或其子窗口的引用。例如,您可以使用传递给handler函数的按钮参数:
handler: function(button, e){..。
success: function(form,action) {
button.up('.window').close();
},或者,由于您显然已经在一个变量(win)中拥有了该窗口,您可以使用该变量来关闭该窗口:
win.close();但这取决于成功函数中是否有可用的变量win,我们不能从您给出的代码中假定这一点。
https://stackoverflow.com/questions/9456331
复制相似问题