PDA

View Full Version : Why are Ext.application.launch() and view.initComponent() being called twice?



chaddjohnson
31 Jan 2013, 9:33 AM
For some reason, my Ext.application launch() method is being called twice. Additionally, some controls (such as windows constrained inside a panel to emulate an MDI) are being rendered twice.

Here is app.js:



Ext.Loader.setConfig({
enabled: true
});

Ext.application({
name: 'MyApp',
appFolder: '/Scripts/desktop/app',

controllers: [
'Main'
],

launch: function() {
console.log('launch()');
Ext.create('MyApp.view.Main');
}
});


and app/controller/Main.js (controller):



Ext.define('MyApp.controller.Main', {
extend: 'Ext.app.Controller'
});


and app/view/Main.js:



Ext.define('MyApp.view.Main', {
xtype: 'mainview',
extend: 'Ext.container.Viewport',

initComponent: function() {
console.log('initComponent()');
var self = this;
this.callParent(arguments);
}
});


Both "launch()" and "initComponent()" are logged to the console twice, each. Any ideas why?

I'm using ExtJS 4.1.

chaddjohnson
31 Jan 2013, 10:20 AM
Apparently this.callParent(arguments) needs to be called inside (at the end of) launch(). This solved my problem. Now both launch() and initComponent() are only called once, each.

chaddjohnson
31 Jan 2013, 11:55 AM
Actually, I don't think this completely solved the problem. Now I get


Uncaught TypeError: Cannot call method 'apply' of undefined

because of the added call, this.callParent(arguments).


*EDIT* Okay, I actually was including app.js twice in the HTML. Jeez. Don't know how I missed this.