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 currently does not support removal of controllers out of the box. To cleanup a controller, do the following:
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. 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
.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.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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With