Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Delete controller 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.

like image 599
Oleg Avatar asked Sep 08 '12 12:09

Oleg


2 Answers

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.
like image 137
mistaecko Avatar answered Nov 18 '22 08:11

mistaecko


A Premium Member request has been initiated on the Sencha forums. Unfortunately, the original request has been there since August with no word. I've just bumped that request with reference to this thread.

The Sencha Forum Topic (Premium section)

like image 28
MikeC Avatar answered Nov 18 '22 10:11

MikeC