Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1173 in 2.0.
  1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    60
    Vote Rating
    0
    stirucherai is on a distinguished road

      0  

    Default 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. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    436
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    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.

  3. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    60
    Vote Rating
    0
    stirucherai is on a distinguished road

      0  

    Default 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])
    }
    }

  4. #4
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,156
    Vote Rating
    4
    rdougan is on a distinguished road

      0  

    Default


    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.

  5. #5
    Sencha User
    Join Date
    Aug 2011
    Posts
    60
    Vote Rating
    0
    stirucherai is on a distinguished road

      0  

    Default


    Thanks,

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

  6. #6
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,156
    Vote Rating
    4
    rdougan is on a distinguished road

      0  

    Default


    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.

  7. #7
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,156
    Vote Rating
    4
    rdougan is on a distinguished road

      0  

    Default


    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.