PDA

View Full Version : Can't get element after extension and some his properties



jsknight
21 Sep 2009, 1:00 AM
Hello,

After class extension I can't get the element wrapper so getEl return null also getWidth returns this.getResizeEl() is undefined error.

1) box.js - sub-class of Ext.Panel



Ext.namespace('Ext.xxx');

Ext.xxx.MyBox = function(config) {

if (Ext.isEmpty(config.layout)) {
config.layout = 'anchor';
}

if (Ext.isEmpty(config.anchor)) {
config.anchor = '100%';
}

// call parent constructor
Ext.xxx.MyBox.superclass.constructor.call(this, config);
};

Ext.extend(Ext.xxx.MyBox, Ext.Panel, {});
2) Create instance of Ext.xxx.MyBox



var box = new Ext.xxx.MyBox({
id: 'test-box-id',
title: 'TestBox',
width: 400,
});

console.dir(box);
console.log('==============');
console.log('getEl: ' + box.getEl());
console.log('getId: ' + box.getId());
console.log(box.getWidth());

Any idea?
Thanks in advance.

jsknight
21 Sep 2009, 2:33 AM
Something wrong in my actions?

jsknight
21 Sep 2009, 2:42 AM
Issue can be closed.
I've found error in the sequence of code flow.

aconran
21 Sep 2009, 4:14 AM
jsknight -

The reason you were not able to access the element was because it had not been rendered yet.

If you were to have used the renderTo configuration or had placed box within another container you would have been able to access the element.