1. #1
    Sencha User
    Join Date
    Jun 2009
    Posts
    399
    Vote Rating
    2
    parky128 is on a distinguished road

      0  

    Default 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:

    Code:
    this._application.on( { 'logout': function() {  
                    
                    this._logoutHandler();
            },scope: this});
    I can still do this in PR4, but also note from the documentation I could setup a listeners config object like so:

    Code:
    listeners: {
                logout: { fn: this._logoutHandler, scope: this }
            }
    But this wont work for me, can I use this listeners object to listen for custom events?

  2. #2
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    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.

  3. #3
    Sencha User Saeven's Avatar
    Join Date
    Mar 2007
    Location
    Ottawa, Canada
    Posts
    419
    Vote Rating
    1
    Saeven is on a distinguished road

      1  

    Question 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).

    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' );
    		            	}
    		            },
    ....
    Where would I add the app-level listener to listen to the galleryLoad event?

    Thanks again.
    Alex
    S. Alexandre Lemaire
    Senior Architect
    saeven.net consulting inc.

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi