ExtJS中this.form.el is undefined

在ExtJS中,经常会需要用到一个窗口中嵌入一个form表单,进行表单提交,如下:

				NewsTypesWindow=function(config){
					config=config||{};
					var formPanel=new Ext.form.FormPanel({
						labelWidth:80,
						url:mvcUrl,
						labelAlign:'right',
						defaults:{
							 anchor: '-20'
						},
						items:[
							{xtype:'textfield',fieldLabel:'分类名称',name:'type_name',id:'type_name'},
							{xtype:'textarea',fieldLabel:'分类描述',name:'type_desc',id:'type_desc'}
						]
					});
					var thiz=this;
					Ext.apply(config,{
						width:300,
						height:180,
						iconCls:'news_window',
						items:[formPanel],
						buttons:[
									{xtype:'button',text:'提交',iconCls:'save',handler:function(){
										formPanel.getForm().submit({params:{
											MVC_BUS:'NewTypes',
											MVC_ACTION:'add'
										}});
										thiz.close();
									}},
									{xtype:'button',text:'关闭',iconCls:'delete',handler:function(){
										thiz.close();
									}}
					   ]
					});
					NewsTypesWindow.superclass.constructor.call(this,config);
				};
				
				Ext.extend(NewsTypesWindow,Ext.Window,{});
				

提交表单并且关闭窗口。这个时候,会报出this.form.el is undefined的错误。

因为form在提交表单的时候,ajax提交表单是基于iframe的,需要去取window里面form的值,而form的window已经被异步的销毁,form dom已经回收。

正常情况下需要回调调用,如下:

									{xtype:'button',text:'提交',iconCls:'save',handler:function(){
										formPanel.getForm().submit({params:{
											MVC_BUS:'NewTypes',
											MVC_ACTION:'add'
										},success:function(form,action){
											thiz.close();
										},failure:function(form,action){
											thiz.close();
										}});
										
									}},




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值