-
2 Dec 2011 3:39 AM #1
Destorying a button (itself) gives Uncaught TypeError: Cannot call method 'removeCls'
Destorying a button (itself) gives Uncaught TypeError: Cannot call method 'removeCls'
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.
-
2 Dec 2011 9:34 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
This is giving me no issues:
Code:var btn = Ext.create('Ext.Button', { text : 'hi' }); var cnt = Ext.Viewport.add({ items : btn }); setTimeout(function() { btn.destroy(); }, 1000);Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
2 Dec 2011 8:51 PM #3
Try deleting the button on tap and check the console.log
Try deleting the button on tap and check the console.log
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])
}
}
-
3 Dec 2011 3:31 PM #4
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.
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
3 Dec 2011 4:58 PM #5
Thanks,
But this problem was not in Sencha 1.1 -- I see this error only in Sencha 2.0
-
3 Dec 2011 4:59 PM #6
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..
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
5 Dec 2011 12:28 PM #7
Are you sure you are on PR2? This seems to be already fixed.
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1173
in
2.0.


Reply With Quote