如何删除控制器 ExtJS? [英] How to Delete controller ExtJS?
本文介绍了如何删除控制器 ExtJS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我像这样在我的应用程序中动态创建控制器:
I dynamically create controllers in my application like this:
var loadedController = me.app.getController(controller_name);
loadedController.init();
使用后如何删除此控制器?谢谢.
How can I delete this controller after using? Thanks.
推荐答案
ExtJs 目前不支持移除开箱即用的控制器.要清理控制器,请执行以下操作:
ExtJs currently does not support removal of controllers out of the box. To cleanup a controller, do the following:
- 使用方法
uncontrol
扩展Ext.app.EventBus
,该方法取消注册此控制器在 EventBus 上注册的所有事件侦听器.查看Ext.app.EventBus#control
的源代码以获取实现.或者使用这个. - 使用
removeController
方法扩展Ext.app.Application
,该方法从controllers
集合中删除给定的控制器实例.它是一个 Ext.util.MixedCollection,查看Ext.app.Application#getController
的源代码.然后使用uncontrol
清除该控制器的所有注册侦听器. - 在您的特定控制器上实现
destroy
方法和/或扩展Ext.app.Controller
.如果适合您的应用程序架构和控制器生命周期,您至少应该调用clearManagedListeners()
并可能销毁此控制器创建的其他对象,如视图或存储.
- Extend
Ext.app.EventBus
with a methoduncontrol
that unregisters all event listeners that this controller registered on the EventBus. Check out the source ofExt.app.EventBus#control
to derive an implementation. Or use this one. - Extend
Ext.app.Application
with a methodremoveController
that removes a given controller instance from thecontrollers
collection. It's a Ext.util.MixedCollection, check out the source forExt.app.Application#getController
. Then clean up all registered listeners for that controller usinguncontrol
. - Implement a
destroy
method either on your specific controller and/or extendExt.app.Controller
. You should at least callclearManagedListeners()
and possibly destroy other objects created by this controller like views or stores, if that suits your application architecture and controller life-cycle.
这篇关于如何删除控制器 ExtJS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文