1. #1
    Sencha User
    Join Date
    Oct 2012
    Location
    San Francisco
    Posts
    13
    Answers
    1
    Vote Rating
    0
    antun is on a distinguished road

      0  

    Default Unanswered: Question on referencing objects inside of a view

    Unanswered: Question on referencing objects inside of a view


    I'm new to Sencha (using 4.1.1), so this is probably a very basic quesion. In the code example below, why is a a reference to the panel, and b undefined? Is there a different method I need to use to reference a nested object?

    Code:
    Ext.define('SFC.view.flashcard.Show' ,{
        extend: 'Ext.container.Container',
        alias : 'widget.flashcardshow',
    
    
        layout: 'fit',
    
    
        title : 'Flashcard TODO',
    
    
        store: 'SpanishWords',
    
    
        items : [
            {
                itemId: 'flashWord',
                xtype: 'panel',
                layout: 'hbox',
                title: 'Spanish Flashcards',
                items: [
                    {
                        xtype: 'text',
                        itemId: 'foobar',
                        text: 'palabra'
                    }
                ]
            }
        
        ],  
    
    
        initComponent: function() {
            this.callParent(arguments);
        },
    
    
        updateWord: function(newWord) {
            // THIS WORKS:
            var a = this.getComponent("flashWord");
            console.log(a);
    
    
            // THIS DOES NOT:
            var b = this.ownerCt.getComponent("foobar");
            console.log(b);
        }
    });
    Thanks,

    Antun

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,800
    Answers
    452
    Vote Rating
    603
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    this refers to

    Code:
    SFC.view.flashcard.Show
    getComponent gets a direct child by id, so that's why a works.

    In the second case, you're asking for the parent of

    Code:
    SFC.view.flashcard.Show
    Then trying to get a single child component with an id of foobar, which, obviously, doesn't exist.

    If you did:

    Code:
    var b = a.getComponent("foobar");
    It should work.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Location
    San Francisco
    Posts
    13
    Answers
    1
    Vote Rating
    0
    antun is on a distinguished road

      0  

    Default


    Thank you for the explanation. It works for me now. I ended up doing:

    this.getComponent("flashWord").getComponent("foobar");

    Is there a way to get around having to step through the hierarchy? e.g. an equivalent of getElementById?

    Thanks,

    Antun

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi