How to Delete controller ExtJS? extjs多个app时,删除其他app的controller

ExtJs currently does not support removal of controllers out of the box. To cleanup a controller, do the following:

  • Extend Ext.app.EventBus with a method uncontrol that unregisters all event listeners that this controller registered on the EventBus. Check out the source of Ext.app.EventBus#control to derive an implementation. Or use this one.
  • Extend Ext.app.Application with a method removeController that removes a given controller instance from the controllers collection. It's a Ext.util.MixedCollection, check out the source for Ext.app.Application#getController. Then clean up all registered listeners for that controller using uncontrol.
  • Implement a destroy method either on your specific controller and/or extend Ext.app.Controller. You should at least call clearManagedListeners() and possibly destroy other objects created by this controller like views or stores, if that suits your application architecture and controller life-cycle.



 source:

Ext.override(Ext.app.EventBus,{
	uncontrol:function(controllerArray){
		var me=this,
			bus=me.bus,
			deleteThis,idx;
			
		Ext.iterate(bus,function(ev,controllers){
			Ext.iterate(controllers,function(query,controller){
				deleteThis=false;
				
				Ext.iterate(controller,function(controlName){
					idx=controllerArray.indexOf(controlName);
					
					if(idx>=0){
						deleteThis=true;
					}
				})
				
				if(deleteThis){
					delete controllers[query];
				}
			})
		})
	}
})


Ext.override(Ext.app.Application,{
	removeController:function(controllerArray){
		var me = this;
        me.eventbus.uncontrol(controllerArray);
	}
})

Ext.override(Ext.app.Controller,{
	destroy:function(){
		var me=this;
			this.clearManagedListeners();
	}
})


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值