Ext中延迟关闭弹窗

最近做毕设,修改密码的时候,会弹窗出来,有一个修改密码框,当修改成功的时候,最下方会有提示,我的需求是修改成功后出提示,2秒后自动关闭窗口,下面是我的代码:


function change_pwd(){
		Ext.apply(top.Ext.form.VTypes,{
			password:function(val,field){
				if(field.initialPassField){
					var pwd = top.Ext.getCmp(field.initialPassField);
					return (val == pwd.getValue());
				}
				return true;
			},
			passwordText:'两次密码不一致'
		});
		Ext.onReady(function(){
			Ext.QuickTips.init();
			var closeWin = new Ext.util.DelayedTask( function(){
				win.close();
			});
			var changePasswordFrom = new top.Ext.form.FormPanel({
				width:360,
				autoHeight:120,
				bodyStyle:"background-color:#99bbe8",
				buttonAlign:'center',
				labelAlign:'right',
				labeWidth:80,
				defaultType:'textfield',
				html : '<center><font color="red"><div id="msg" class="msg"></div></font><font color="green"><div id="tipmsg" class="tipmsg"></div></font></center>',
				defaults:{
					 width:150,
					 allowBlank:false,
					 msgTarget:'under',
					 maxLength:20,
					 maxLengthText:'密码不能超过20位'
					 },
				items:[ 
					{
					 fieldLabel:'用户名',
					 name:'account',
					 value:account,
					 inputType:'textfield',
					 readOnly:true,
					 id:'account'
					},
					{
					 fieldLabel:'旧密码',
					 name:'oldPwd',
					 inputType:'password',
					 blankText:'密码不能为空',
					 id:'oldPwd'
					},{
					 fieldLabel:'新密码',
					 name:'newPwd',
					 inputType:'password',
					 blankText:'密码不能为空',
					 id:'newPwd',
					 minLength:6,
					 minLengthText:'密码不能少于6位'
					},{
					 fieldLabel:'确认新密码',
					 name:'secondPassword',
					 inputType:'password',
					 blankText:'密码不能为空',
					 vtype:'password',
					 initialPassField:'newPwd',
					 minLength:6,
					 minLengthText:'密码不能少于6位'
					},
				]
			});
	
	    var win = new top.Ext.Window({
	        title: "修改密码",
	        width: 360,
	        height: 250,
	        plain: true,
	        bodyStyle:"background-color:#99bbe8",
// 	        autoScroll: true,
	        layout:'fit',
	        //可以随意改变大小
	        resizable: true,
	        //是否可以拖动
	        //draggable:false,
	        collapsible: false, //不允许缩放条
	        closeAction: 'close',
	        closable: true,
	        //弹出模态窗体
	        modal: true,
	        buttonAlign: "center",
	        bodyStyle: "padding:10 10 10 10",
	        border :false, 
	        x:500,
	        y:250,
	        constrain :true,
	        items: [changePasswordFrom],
	        
	        buttons : [{
                         text : "提交",
                         handler : function() {
                            if (changePasswordFrom.getForm().isValid()) {
                                changePasswordFrom.getForm().submit({
                                          url : './dorm_sys/adminAction_sys_changPwd',
                                          success: function(form, response) {
												top.Ext.get("tipmsg").dom.innerHTML = "修改成功";
												top.Ext.get("msg").dom.innerHTML = "";
												closeWin.delay(2000);//延迟2秒关闭窗口
                                          },
                                          failure: function(form, response) {
                                        	  top.Ext.get("tipmsg").dom.innerHTML = "";
                                              top.Ext.get("msg").dom.innerHTML = "修改失败";
                                          }
                                       });
                            }
                         }
                     }, {
                         text:'重置',
						 handler:function(){
								changePasswordFrom.getForm().reset();
						 }
                     }]
                     
                     
	      });
          win.show();
        });
	}

关键代码:

var closeWin = new Ext.util.DelayedTask( function(){
				win.close();
			});

success: function(form, response) {
												top.Ext.get("tipmsg").dom.innerHTML = "修改成功";
												top.Ext.get("msg").dom.innerHTML = "";
												closeWin.delay(2000);//延迟2秒关闭窗口
                                          },


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值