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

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


  • 扩展 Ext.app.EventBus 使用方法 uncontrol 取消注册此控制器在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天全站免登陆