如何删除控制器 ExtJS? [英] How to Delete controller ExtJS?

查看:26
本文介绍了如何删除控制器 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 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.

这篇关于如何删除控制器 ExtJS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆