Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: this.application is undefined

  1. #11
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    @bclover The init method should get the app passed as an argument.

    Code:
    init : function(app) {
        app.on(...);
    }
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  2. #12
    Sencha User
    Join Date
    Feb 2012
    Location
    Raleigh, NC
    Posts
    17

    Default

    @mitchellsimoens Thanks for the tip on passing in the app into the init function as an argument.

    One other thing I have been trying to figure out. Why can't I dispatch an event from my controller using this.application.fireEvent('myCustomEvent')? It keeps telling me 'Uncaught TypeError: Object #<Object> has no method 'fireEvent'

    Oddly enough though, I can dispatch it into the application event bus if I use MyApp.app.fireEvent('myCustomEvent')

    What am I missing?

  3. #13
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    Little example:

    Code:
    Ext.define('Test.controller.Test', {
        extend : 'Ext.app.Controller',
    
        init : function(app) {
            app.on('custom', 'handleCustom', this);
        },
    
        handleCustom : function() {
            console.log('custom event fired');
        }
    });
    
    Ext.application({
        name : 'Test',
    
        controllers : [
            'Test'
        ],
    
        launch: function () {
    
            this.fireEvent('custom', this);
    
        }
    });
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •