PDA

View Full Version : xxx.initComponent is undefined



macgyverx86
26 Nov 2010, 6:25 AM
Hy

I'm trying to show a popup after clicking a button. The button has a handler that creates a new object. The object is defined in a sepparate js file. The content of the file is something like this:



Ext.extend(aaa.bbb.xxx, aaa.bbb.PopupWindow, {
border: false,
defaultButton: 'button',
id: 'id',

initComponent: function (config) {

var okButton = new Ext.Button({
text: 'click',
id: 'button',
disabled: false,
value: '',
});

var config = {
title: 'title'),
id: 'id',
closable: true,
autoDestroy: false,
closeAction: 'hide',
width: 610,
autoHeight: true,
resizable: false,
border: false,
plain: false,
shim: false,
buttonAlign: 'right',
items: [],

buttons: [okButton],
modal: true

};

Ext.apply(this, Ext.apply(this.initialConfig, config));
aaa.bbb.xxx.initComponent.apply(this, arguments);

}

and the handler is:


new aaa.bbb.xxx().showPopup();
When i click the button that shos the popup i get this error:

aaa.bbb.xxx.initComponent is undefined
line: 1
Any help would be appreciated.

Animal
26 Nov 2010, 7:12 AM
aaa.bbb.xxx is a reference to the constructor function.

Members are not stored as properties of the constructor.

Shared members are stored in the prototype of the constructor which is a single object which is shared among all instances created by that constructor.

In fact, you need to call the superclass's initComponent there. Ext.extend helpfully creates a reference to the superclass's prototype in the created constructor. It's called superclass.

macgyverx86
26 Nov 2010, 7:42 AM
Thanks. You where right. I'm calling the initComponent from my class when i should call the initComponent of the superclass :D.
The last line should be like this:

aaa.bbb.xxx.supercalss.initComponent.apply(this, arguments);