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

Thread: Problem updating badge text on tabpanel

  1. #1
    Sencha User davisty's Avatar
    Join Date
    Mar 2010
    Location
    Spanish Fort, Al
    Posts
    285
    Answers
    11

    Default Answered: Problem updating badge text on tabpanel

    Hello,

    Im attempting to update the badge text on a tabpanel. Im attempting to update the badge text whenever there is a card change to show the index. The variable containing the index is correct, but I cant get it to work.

    I have defined the index variable as global, here is my code.There are three items on the tabpanel, Im trying to update is the second and third ones.

    Code:
    var newCardIndex = "";  
    var oldCardIndex = "";
    Code:
    var Panel1 =  new Ext.TabPanel({ 
    listeners: {                                           
    cardswitch: function() {                         
    this.getTabBar().items.items[1].setBadge(newCardIndex);
                              }                            
               }
    Code:
    var carousel2 = new Ext.Carousel({ 
         listeners: {                                              
                beforecardswitch: function (newCard, oldCard, 
                            index, animated) {                
                newCardIndex = carousel2.getActiveIndex();    
                            }                                 
                }

  2. Quote Originally Posted by davisty View Post
    Does your earlier example with the indexOf retrieve a kinda of a getactiveindex on the old card. Meaning I can determine if a user is swipeing/scrolling up/down/left/right based on the oldcard and newcard difference
    Correct. What happened in that line is we got the inner items (leave the docked items out of this) and it returned a Ext.util.MixedCollection. Now we got the index of that class in the MixedCollection using indexOf. This will get the correct index regardless of if you are going forward, backward, or from the end to the start.

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

    Default

    Code:
    new Ext.TabPanel({
        fullscreen : true,
        items      : [
            {
                title : 'One',
                html  : 'one'
            },
            {
                title : 'Two',
                html  : 'two'
            }
        ],
        listeners : {
            cardswitch : function(tabpanel, newTab) {
                var tab = newTab.tab;
    
                tab.setBadge(10);
            }
        }
    });
    However the CSS is totally wrong... the badge gets placed all the way to the right on the toolbar
    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

  4. #3
    Sencha User davisty's Avatar
    Join Date
    Mar 2010
    Location
    Spanish Fort, Al
    Posts
    285
    Answers
    11

    Default

    I retrofitted the code and Im getting the same results.

    The tab item isnt being updated ...

  5. #4
    Sencha User davisty's Avatar
    Join Date
    Mar 2010
    Location
    Spanish Fort, Al
    Posts
    285
    Answers
    11

    Default

    I stand corrected. when displaying the "10" literal it does display. when I try to update with a variable it's not displaying.

    How should I update with a variable?

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

    Default

    Quote Originally Posted by davisty View Post
    I stand corrected. when displaying the "10" literal it does display. when I try to update with a variable it's not displaying.

    How should I update with a variable?
    That shouldn't matter at all.

    Code:
    new Ext.TabPanel({
        fullscreen : true,
        items      : [
            {
                title : 'One',
                html  : 'one'
            },
            {
                title : 'Two',
                html  : 'two'
            }
        ],
        listeners : {
            cardswitch : function(tabpanel, newTab) {
                var tab   = newTab.tab,
                    badge = 10;
    
                tab.setBadge(badge);
            }
        }
    });
    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

  7. #6
    Sencha User davisty's Avatar
    Join Date
    Mar 2010
    Location
    Spanish Fort, Al
    Posts
    285
    Answers
    11

    Default

    Im getting the variable using this :

    listeners: { beforecardswitch: function (newCard, oldCard, index, animated) {
    newCardIndex = carousel2.getActiveIndex(); } }
    newCardIndex is not being displayed ...It's correct though. Im display it in an alert message. But it's not showing in the badge.

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

    Default

    Why are you using beforecardswtich? Why not get the index of the 3rd argument in the cardswitch event which is the old card?

    Code:
    cardswitch: function(tabpanel, newCard, oldCard) {
        var index = tabpanel.items.indexOf(oldCard);
    }
    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

  9. #8
    Sencha User davisty's Avatar
    Join Date
    Mar 2010
    Location
    Spanish Fort, Al
    Posts
    285
    Answers
    11

    Default

    Sorry it took so long to reply, we were disconnected ...

    Ive used many listeners, thinking that was the problem.

    But, is this adding a new item to the tabbar, because Im not wanting to do that. I want to update a particular tab with the cardswitch index, because their going to be swiping up/down/left/right and Im trying to keep up with the position of the matrix their going to be at ...

    Hope Im making sense ...

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

    Default

    No, it is adding an element within the tab instance
    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

  11. #10
    Sencha User davisty's Avatar
    Join Date
    Mar 2010
    Location
    Spanish Fort, Al
    Posts
    285
    Answers
    11

    Default

    Im not sure what you mean ?

    Im trying to keep up, but Im kinda new at this ...

    I have three tabs. catagory 1, catagory 2, and catagory 3.

    Say for instance, that Im swiping/scrolling on say catagory 2, I want to display the cardswipe index in the badge text for tab catagory 2.

    I thought I had it but I cant get the variable to display in the badge text.

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
  •