PDA

View Full Version : Extending the enter App class



alfa19
15 Jan 2014, 2:26 AM
Hi all,

i start my application with this inline code:


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

//Set application namespace infos
Ext.Loader.setPath('MyApp', 'my/app');

//App is the entry point class
Ext.require([
'MyApp.App'
]);

Ext.onReady(function(){
//Init the application
Ext.create('MyApp.App').init();
});

All works fine.
Now i'm trying to extend the App class. So i have MyApp.ParentApp:


Ext.define('MyApp.ParentApp', {

myFunction: function(){
//Do something
}

});

And the MyApp.App become:


Ext.define('MyApp.App', {
extend: 'MyApp.ParentApp',

init: function(){
console.log("App init start");
this.myFunction();
console.log("App init end");
}

});

In this way nothing happens, the init method wasn't call. If i remove the extend all works fine (obviously i get an error of undefined myFunction in this case).

I hope I was clear, thanks for your help

EDIT: i've just found the solution. With extend the Ext.require must be into the onReady() function.

Gary Schlosberg
16 Jan 2014, 11:51 AM
Glad to see you found the solution, and thanks for sharing with the community.