PDA

View Full Version : [FIXED] Destorying a button (itself) gives Uncaught TypeError: Cannot call method 'removeCls'



stirucherai
2 Dec 2011, 3:39 AM
Hi,

I have defined button (using ICONCLS) with-in a panel. As part of the handler (ontap), I preform some action and wanted to remove the button (that was tapped/pressed).

I used panel.items.items[index for the button].destroy(), while the button is getting deleted/destroyed i get error

52467 me.releasedTimeout = setTimeout(function() {
52468 me.element.removeCls(me.getPressedCls());

Basically me.element is null (as it has been removed)

I tried used panel.remove(button item) the result is same.


Is this a bug or there someother way of doing the same.

mitchellsimoens
2 Dec 2011, 9:34 AM
This is giving me no issues:


var btn = Ext.create('Ext.Button', {
text : 'hi'
});

var cnt = Ext.Viewport.add({
items : btn
});

setTimeout(function() {
btn.destroy();
}, 1000);

stirucherai
2 Dec 2011, 8:51 PM
Hi,

I tried deleting from javascript console and it works no issues. Issue is deleting the button when the button itself was pressed -- meaning on its own handler
actionBar.add ({
iconcls:'backButton'
,handler:function(b,e){
<Some code>
actionBar.remove(actionBar.items.items[0])
}
}

rdougan
3 Dec 2011, 3:31 PM
Makes sense. It is because there is a timeout for the pressedCls, which is then going to try and remove it, from a button, which, no longer exists.

stirucherai
3 Dec 2011, 4:58 PM
Thanks,

But this problem was not in Sencha 1.1 -- I see this error only in Sencha 2.0

rdougan
3 Dec 2011, 4:59 PM
Yeah, I've added it as a bug to ST 2.0. As you know, ST is just in it's preview stage, so there are a few little issues like this..

rdougan
5 Dec 2011, 12:28 PM
Are you sure you are on PR2? This seems to be already fixed.