Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha - Community Support Team
    Join Date
    Jun 2010
    Posts
    220
    Vote Rating
    0
    meyerovb is on a distinguished road

      0  

    Default getCard not available from tab activate listener

    getCard not available from tab activate listener


    First alert says 'C1', second alert says 'undefined'
    Code:
    Ext.setup({ onReady: function () {
    new Ext.TabPanel({ fullscreen: true, items: [{ title: 'I1' }, { title: 'I2', card: 'C1', 
    listeners: { activate: function () { alert(this.card); alert(this.getCard); } }}] });
    } });

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    8
    TommyMaintz will become famous soon enough

      0  

    Default


    We don't have a property (nor a method if you would add parentheses) called getCard and don't see a definition.

    You could do the following.
    Code:
    Ext.setup({ 
        onReady: function () {
            new Ext.TabPanel({
                fullscreen: true, 
                items: [{
                    title: 'I1' 
                }, {
                    title: 'I2', 
                    card: 'C1',
                    getCard: function() {
                        return this.card;
                    },
                    listeners: {
                        activate: function () {
                            alert(this.card); 
                            alert(this.getCard()); 
                        } 
                    }
                }] 
            });
        } 
    });

  3. #3
    Sencha - Community Support Team
    Join Date
    Jun 2010
    Posts
    220
    Vote Rating
    0
    meyerovb is on a distinguished road

      0  

    Default


    Note: card is not listed as a public property in the Tab documentation.

    The reason I was expecting getCard to be there:
    If you click on Ext.Tab in the documentation to see the source (http://www.sencha.com/deploy/touch/d...ml#cls-Ext.Tab) you can see the following:

    /**
    * Retrieves a reference to the card associated with this tab
    * @returns {Mixed} card
    */
    getCard : function() {
    return this.card;
    },

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    8
    TommyMaintz will become famous soon enough

      0  

    Default


    Ah, only now I see what you were trying to do. I never really thought about the fact that people would want to change the card associated to a tab. Thus the fact that it is private and not documented.

    Anyway, the reason this.setCard is not defined is because of the scope that the activate handler runs in by default. "this" inside your handler refers to the card, not the tab.

    Try applying the following patch (which will probably be part of the next release)
    Code:
    Ext.override(Ext.TabBar, {
        // @private
        onCardAdd : function(panel, card) {
            card.tab = this.add({
                xtype: 'tab',
                card: card
            });
        },
    
        // @private
        onCardRemove : function(panel, card) {
            var items = this.items.items,
                ln = items.length,
                i, item;
    
            for (i = 0; i < ln; i++) {
                item = items[i];
                if (item.card === card) {
                    item.card = null;
                    this.remove(item, true);
                    return;
                }
            }
        }
    });
    then you should be able to do the following in your event handler.

    Code:
    this.tab.setCard(...);

  5. #5
    Sencha - Community Support Team
    Join Date
    Jun 2010
    Posts
    220
    Vote Rating
    0
    meyerovb is on a distinguished road

      0  

    Default


    Actually I pasted in setCard by mistake I am using getCard because I'm simulating the twitter example, but instead of referencing the twitter panel as a variable, I add the following to my tab panel:

    { iconCls: 'chat', card: new twitter.TimeLine(), title: 'Twitter', listeners: { activate: function () { this.card.store.read(); } }}

    I first tried this.getCard() based on the documentation script, but it didn't work. Thanks for the workaround

  6. #6
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    8
    TommyMaintz will become famous soon enough

      0  

    Default


    In that case you don't need to apply my patch with that override. Like I mentioned before, the default scope of the activate event is the card itself.

    In your case you could just do this.store.read();

  7. #7
    Sencha - Community Support Team
    Join Date
    Jun 2010
    Posts
    220
    Vote Rating
    0
    meyerovb is on a distinguished road

      0  

    Default


    Now I get why I was confused... the Tab documentation read:

    activate : ( Ext.Tab this )

    Listeners will be called with the following arguments:
    • this : Ext.Tab
    I assumed this meant the context of the call, not the parameter that gets passed in. So the context is the card, the parameter is the tab, and you still can't call getCard on the tab... got it, thanks. You may want to look into clearing up the documentation, using 'this' as a parameter name can lead to confusion

  8. #8
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    8
    TommyMaintz will become famous soon enough

      0  

    Default


    Totally agree. At least we are all on the same page now.

Similar Threads

  1. Tabs activate listener - odd behavior
    By str2etboy in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 20 Jun 2008, 9:53 AM
  2. how to get tab panel title from activate listener
    By vik in forum Ext 2.x: Help & Discussion
    Replies: 7
    Last Post: 29 May 2008, 9:58 AM
  3. How to activate a tab
    By leewu in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 11 Feb 2008, 5:17 PM
  4. How to activate a tab with only ID's?
    By aaronshaf in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 4 Nov 2007, 10:01 AM
  5. can i set 'activate' tab or 'disable' tab with dialog's 'autoTabs'?
    By perthkit in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 26 Jul 2007, 10:11 PM

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar