PDA

View Full Version : exntending Window class - constructor



lormitto
5 Mar 2010, 3:20 AM
Thank to your help I tried to learn how to extend objects.
I used code presented in tutorial however i stuck with constructor definition.
My purpose is to send id to object via constructor. In fact I do not know how to modify it to achive it. Do you have any experiance with that?


classMainWindow = Ext.extend(Ext.Window, {

border:false
,constructor:function(config) {

config = config || {};
config.listeners = config.listeners || {};
Ext.applyIf(config.listeners, {
expand:{scope:this, fn:function() {
}}
,collapse:{scope:this, fn:function() {
}}
});


classMainWindow.superclass.constructor.apply(this, arguments);

}
,initComponent:function() {

var config = {
};

Ext.apply(this, config);
Ext.apply(this.initialConfig, config);

classMainWindow.superclass.initComponent.apply(this, arguments);


}
,onRender:function() {

classMainWindow.superclass.onRender.apply(this, arguments);

}

});

Ext.reg('classMainWindow', classMainWindow);

Animal
5 Mar 2010, 3:23 AM
You pass the id in as a property of the config object.

lormitto
5 Mar 2010, 3:27 AM
You pass the id in as a property of the config object.


Perhaps that's the influence of other programming languages but...

will I be able to use it like this

var someVariable = new classMainWindow(idHere);


?

Config object is something completly new for me.

Animal
5 Mar 2010, 3:57 AM
Read the docs and examples.

Learn Javascript.

id is a property of the config object.