-
25 Jan 2012 4:35 AM #1
How to listen for custom events fired in application
How to listen for custom events fired in application
Hi,
I am just switching in the PR4 release into my application, and am restructuring my controller files as per the latest documentation.
I have a logout event being fired in my application, and in PR3 I would do something like this in the controller:
I can still do this in PR4, but also note from the documentation I could setup a listeners config object like so:Code:this._application.on( { 'logout': function() { this._logoutHandler(); },scope: this});
But this wont work for me, can I use this listeners object to listen for custom events?Code:listeners: { logout: { fn: this._logoutHandler, scope: this } }
-
25 Jan 2012 10:34 AM #2
That should work, but just remember that he listeners must still be added onto the application instance, and not your controller (which is where they would be going if you put them inside the config: {} block). You should so something like this in your controller:
Code:this.getApplication().on({ logout: this.logoutHandler, scope: this });Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
15 Feb 2012 10:53 AM #3
Same Question...
Same Question...
Hi,
I have the exact same question (problem). I have an application that contains a list, and I was hopeful to have that list's selection event fire out to an application-level listener (because they all fire a common routine).
Where would I add the app-level listener to listen to the galleryLoad event?Code:Ext.application({ name: 'test', launch: function() { Ext.create("Ext.Panel", { fullscreen: true, layout: 'vbox', items: [ { xtype: 'list', flex: 5, store: new Ext.data.Store({ ... }), listeners: { select: function( view, record ) { this.fireEvent( 'galleryLoad' ); } }, ....
Thanks again.
AlexS. Alexandre Lemaire
Senior Architect
saeven.net consulting inc.


Reply With Quote