Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: down(String selector) method from Container class is not working anymore

  1. #1

    Default down(String selector) method from Container class is not working anymore

    For example I have a panel "view" that contains a button with ID myButton.
    In touch 1 and touch 2 pr1, I can select the button with view.down('#myButton')

    The down method works in touch 2 pr1, but it doesn't any more in pr2 or pr3.
    Is there any alternatives in new versions?

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    Works for me in PR3:

    Code:
    var cnt = Ext.create('Ext.Container', {
        fullscreen : true,
        items      : [
            {
                xtype  : 'button',
                itemId : 'myButton',
                text   : 'Test'
            },
            {
                xtype  : 'toolbar',
                docked : 'top',
                items  : [
                    {
                        xtype  : 'button',
                        itemId : 'myButton',
                        text   : 'Hello'
                    }
                ]
            }
        ]
    });
    
    console.log(cnt.down('#myButton'));
    console.log(cnt.down('toolbar #myButton'));
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    127

    Default

    I ran into this exact issue with PR3. Something has changed. I fixed it by not using this.down() in my custom view but using down() on a specific element like Mitchell pointed out above.

  4. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    Quote Originally Posted by robl View Post
    I ran into this exact issue with PR3. Something has changed. I fixed it by not using this.down() in my custom view but using down() on a specific element like Mitchell pointed out above.
    Not element... component
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  5. #5

    Default

    Quote Originally Posted by mitchellsimoens View Post
    Works for me in PR3:

    Code:
    var cnt = Ext.create('Ext.Container', {
        fullscreen : true,
        items      : [
            {
                xtype  : 'button',
                itemId : 'myButton',
                text   : 'Test'
            },
            {
                xtype  : 'toolbar',
                docked : 'top',
                items  : [
                    {
                        xtype  : 'button',
                        itemId : 'myButton',
                        text   : 'Hello'
                    }
                ]
            }
        ]
    });
    
    console.log(cnt.down('#myButton'));
    console.log(cnt.down('toolbar #myButton'));
    What I see different here is the itemId keyword, I thought it was previously id instead.
    Can you explain more about the change?

  6. #6
    Sencha User
    Join Date
    Oct 2011
    Posts
    127

    Default

    Quote Originally Posted by mitchellsimoens View Post
    Not element... component
    Yes, I meant "component" but wrote "element". Thanks.

  7. #7
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    Quote Originally Posted by phamtieugiao View Post
    What I see different here is the itemId keyword, I thought it was previously id instead.
    Can you explain more about the change?
    I never use id unless debugging. itemId should be a unique id to it's parent. As you can see by my example, I use the same itemId but since they have 2 different parents they are still unique.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  8. #8

    Default

    Tested, if I put like this:
    Code:
            Ext.apply(this, {
                _itemId: this.name + 'Button'
            });
    . Notice the '_' character. Then the down() method works.

    Seems like Ext.apply doesn't change the _itemId if declared like this:
    Code:
            Ext.apply(this, {
                itemId: this.name + 'Button'
            });

  9. #9
    Sencha User rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,159

    Default

    Where are you adding that code? You should never do that anymore. You should always use the setter (setItemId).
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  10. #10

    Default

    Quote Originally Posted by rdougan View Post
    Where are you adding that code? You should never do that anymore. You should always use the setter (setItemId).
    I added it in initialize section:
    Code:
        initialize: function(config) {
            this.initConfig(config);
            Ext.apply(this, {
                 _itemId: this.name + 'Button'
            });
            this.callParent(arguments);
        }

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •