0
votes

I'm really new to ExtJS and I just spent several hours trying to solve this but couldn't. I have a controller with an 'onLaunch' function but it is never called.

I included the .js file of my controller in the application 'launch' function. This is why I changed the 'init' function of the controller to 'onLaunch', I read that 'init' is called before application 'launch' and 'onLaunch' after.

I checked with a 'console.log' that my .js file is read and it is, so I don't understand why the 'onLaunch' function isn't...

Here the controller file, the code is really simple, this my first application and I wanted to try some things before starting :

console.log('BROWSER CONTROL');

Ext.define('WSR.controller.BrowserControl', {

    extend: 'Ext.app.Controller',

    views: [
        'Browser'
    ],

    onLaunch: function() {
        console.log('ONLAUNCH BrowserControl');

        this.control({
            'viewport > panel': {
                render: this.onPanelRendered
            },
            'browser': {
                selectionchange: this.onSelectionChanged
            }
        });
    },

    onPanelRendered: function() {
        console.log('PanelRendered');
    },

    onSelectionChanged: function() {
        console.log('SelectionChanged');
    }
});

In Firebug console I can see the 'BROWER CONTROL' message but never the 'ONLAUNCH' one.

Can someone help me ?

1

1 Answers

2
votes

Your code just defines the class (that's what Ext.Define method is for), but doesn't instantiate it. You need to call Ext.create on the defined class to actually create an instance. I suspect that your onLaunch function will be called then. (See the ExtJS documentation I linked for more information.)