PDA

View Full Version : Error on collapse listener



rafaelrp
16 Apr 2012, 6:48 AM
I'm getting this error on collapse listener.


me.el is null

listener code:


collapse: {
fn: function(){
var centerWidth = Ext.getCmp('centerPanel').getWidth();
var centerHeight = Ext.getCmp('centerPanel').getHeight();

console.info("centerWidth: "+centerWidth);
console.info("centerHeight: "+centerHeight);
}


Thanks ! ~o)

scottmartin
16 Apr 2012, 7:47 AM
Please try the following:



Ext.create('Ext.panel.Panel', {
id: 'centerPanel',
title: 'Hello',
width: 300,
collapsible: true,
html: '<p>World!</p>',
renderTo: Ext.getBody(),

collapse: function(){
var centerWidth = Ext.getCmp('centerPanel').getWidth();
var centerHeight = Ext.getCmp('centerPanel').getHeight();

console.info("centerWidth: "+centerWidth);
console.info("centerHeight: "+centerHeight);
}
}

});


result from console:
centerWidth: 300
centerHeight: 42

Regards,
Scott.

rafaelrp
16 Apr 2012, 8:29 AM
it worked but the panel doesn't collapse after i click on the collapse button.

~o)

scottmartin
16 Apr 2012, 9:45 AM
I must have been asleep when I answered this ...

try:


Ext.create('Ext.panel.Panel', {
id: 'centerPanel',
title: 'Hello',
width: 300,
collapsible: true,
html: '<p>World!</p>',
renderTo: Ext.getBody(),

listeners: {

collapse: function(){
var centerWidth = Ext.getCmp('centerPanel').getWidth();
var centerHeight = Ext.getCmp('centerPanel').getHeight();

console.info("centerWidth: "+centerWidth);
console.info("centerHeight: "+centerHeight);
}
}

});


Regards,
Scott.