Loading ...
Sorry, an error occurred while loading the content.

Tabview :: check if tab already exists

Expand Messages
  • Andrew
    Hi, I have just started messing around with YUI tabviews. I am trying to create something like the new yahoo mail interface where you can click an object and
    Message 1 of 2 , Mar 1 6:29 AM
    • 0 Attachment
      Hi,

      I have just started messing around with YUI tabviews.

      I am trying to create something like the new yahoo mail interface
      where you can click an object and have it open in a new tab - and I
      have this working :-)

      What I would like to be able to do if check to see if the tab already
      exists, and if so activate it, other wise create a new tab.

      Then after that, I will want to have a close tab icon (x) that can be
      clicked on to close the tab.

      Any tips would be greatly appreciated.

      TIA

      regards
      Andrew
    • Dave Parsons
      ... I m trying to do a very similar thing. For close button, see here: http://blog.davglass.com/files/yui/tab3/ As for finding a tab, I found a way to do it.
      Message 2 of 2 , Mar 2 2:45 PM
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "Andrew" <ajmercer@...> wrote:
        > What I would like to be able to do if check to see if the tab already
        > exists, and if so activate it, other wise create a new tab.
        >
        > Then after that, I will want to have a close tab icon (x) that can be
        > clicked on to close the tab.

        I'm trying to do a very similar thing.

        For close button, see here:
        http://blog.davglass.com/files/yui/tab3/

        As for finding a tab, I found a way to do it. I'm still fumbling my
        way around YUI, so it may not be the best way:

        function displayInfo(type, id, visId) {
        // If the tab already exists, open it
        var tabArray = myTabs.get('tabs');
        for (var idx=0; idx < tabArray.length; idx++) {
        if (id == tabArray[idx].airportId) {
        myTabs.set('activeTab', tabArray[idx]);
        return;
        }
        }

        // Create the new tab
        var newTab = new YAHOO.widget.Tab({
        label: visId,
        dataSrc: 'getinfo.php?' + type + '=' + id,
        href: '#' + visId,
        active: true
        });
        myTabs.addTab(newTab);
        newTab.airportId = id;
        }

        Hope that helps,
        Dave
      Your message has been successfully submitted and would be delivered to recipients shortly.