1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    30
    Vote Rating
    0
    mscifo is on a distinguished road

      0  

    Default Closing a tab shows a hidden panel

    Closing a tab shows a hidden panel


    Jack

    I've created three panels and hidden the second and third one, show only the first tab/panel shows. I am using your code to dynamically create a new tab. Once a new tab is created, 2 tabs show up, the first panel and the new panel. However, when I close the newly created tab, instead of activating the first tab/panel, the 3rd hidden panel shows up. What should happen is when you close a tab then only visible panels should be shown. Better yet, it would be great if the tab code kept track of your tab selections so when a tab is closed, the previously selected tab is selected.

    -Matt

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    16
    jack.slocum will become famous soon enough

      0  

    Default


    I've fixed this and it will be in the next release.

    I also separated the logic for selecting the next tab into it's own function that you can override to implement another kind of tab selection.

    Jack

  3. #3
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    16
    jack.slocum will become famous soon enough

      0  

    Default


    Here's a patch for you.

    Code:
    YAHOO.ext.TabPanel.prototype.removeTab = function(id){
            var items = this.items;
            var tab = items[id];
            if(!tab) return;
            var index = items.indexOf(tab);
            if(this.active == tab && items.length > 1){
                var newTab = this.getNextAvailable(index);
                if(newTab)newTab.activate();
            }
            this.stripEl.dom.removeChild(tab.pnode.dom);
            this.bodyEl.dom.removeChild(tab.bodyEl.dom);
            items.splice(index, 1);
            delete items[tab.id];
            this.autoSizeTabs();
        };
        
    YAHOO.ext.TabPanel.prototype.getNextAvailable = function(start){
            var items = this.items;
            var index = start;
            // look for a next tab that will slide over to
            // replace the one being removed
            while(index < items.length){
                var item = items[++index];
                if(item && !item.isHidden()){
                    return item;
                }
            }
            // if one isn't found select the previous tab (on the left)
            var index = start;
            while(index >= 0){
                var item = items[--index];
                if(item && !item.isHidden()){
                    return item;
                }
            }
            return null;
        };

Similar Threads

  1. Javascript Console Shows CSS Problems
    By cklester in forum Ext 1.x: Help & Discussion
    Replies: 4
    Last Post: 23 Mar 2007, 11:58 AM
  2. IE7 refreshes after closing a tabbed content panel
    By mdocter in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 9 Mar 2007, 3:29 PM
  3. Closing Tab doesn't complete destroy panel
    By vtswingkid in forum Ext 1.x: Bugs
    Replies: 11
    Last Post: 20 Jan 2007, 6:23 AM
  4. The grid column title shows {1} in dialog in IE
    By davy_wei in forum Ext 1.x: Bugs
    Replies: 5
    Last Post: 8 Jan 2007, 10:51 AM
  5. BorderLayout: Panel sometimes shows tabs, sometimes not
    By thejoker101 in forum Ext 1.x: Bugs
    Replies: 2
    Last Post: 31 Dec 2006, 2:19 AM

Thread Participants: 1