For the moment, when I'm in a controller and that I want to call a function from another controller, I do this :
App.app.getControllerInstances()['App.controller.OtherController'].do_something();
Is seems a bit heavy to me, is there another (better) way to do this ?
Thanks
When using the MVC convention in Sencha Touch 2, I would recommend the following when trying to call a method called 'SomeMethodInB' in 'ControllerB' from inside 'ControllerA':
'MyAppName' is the name of the app you defined in the core app definition - typically in your app.js file.
According to the Sencha forums, the below is depreciated:
http://www.sencha.com/forum/showthread.php?158996
In fact the only way I can call the "this.getApplication()" method to even work is when calling it from my app definition file (app.js).
If you're not in the context of your Controller(for example in a callback function of some object), you can do this.
I would use the getController method: http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Application-method-getController
EG:
this.getApplication().getController('ControllerName').doSomething();