PDA

View Full Version : Controller events



mrtedweb
13 Apr 2013, 4:07 AM
I am using ExtJS4 with MVC and came across a situation where I need a controller to fire off a custom event, and another controller to listen to that event. I have not been able to get this to work yet. Is this possible?

mrtedweb
13 Apr 2013, 4:38 AM
In order to accomplish this, I had to fire the custom event from a view component of one controller in order for another controller to be able to listen to it. I guess controllers can't listen to one another directly.

girish.arjunagi
13 Apr 2013, 7:53 AM
Why can't you try firing a event on Ext.util.Observable object. While can be listened in the other controller as well.:-?

fliptight
13 Apr 2013, 11:00 AM
The ability to communicate among controllers is actually explained in ExtJS "Architecting Your App" guide.

http://docs.sencha.com/ext-js/4-0/#!/guide/mvc_pt3

Every controller receives a reference to the application controller and that reference is used to fire off events that other controllers can listen for.

quixit
3 May 2013, 10:31 PM
In order to accomplish this, I had to fire the custom event from a view component of one controller in order for another controller to be able to listen to it. I guess controllers can't listen to one another directly.

This is not right anymore. See http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.app.Controller-method-listen
Keyword: Controller event domain.