Tabs Tutorial

API Reference - Advanced Features

There are two object classes/types that you may work with: Tab and TabSystem. I'll discuss the TabSystem object type first.

What Exactly is a TabSystem?

A TabSystem is an object class.

A TabSystem instance can be obtained with the following JavaScript code:

var ts = TabSystem.list[sElementId];

What Can I Do with a TabSystem?

A TabSystem instance has methods that allow you to many things:

Properties and Methods

var ts = TabSystem.list[sElementId];

var activeTab  = ts.activeTab; // the currently active tab
var relatedTab = ts.relatedTab; // the last tab that was active
var nextTab    = ts.nextTab; // the tab that is about to activate
var tabEls     = ts.tabArray; // array of tab elements
var tabs       = ts.tabs; // array of Tab instances
var b          = (tabEls[0] == tabs[0].el); // true!
var tabParams  = ts.tabParams;


// the this keyword refers to the TabSystem instance.
ts.addEventListener("onbeforechange", function(){ alert(this.nextTab.id);} );
ts.addEventListener("onchange", function(){ alert(this.activeTab.id);} );

What is a Tab?

Tab is an object class. A Tab instance is tied to a TabSystem instance. You can get a reference to a Tab instance two ways:

  1. Through a reference to its TabSystem like this:
    // First get a TabSystem.
    var ts = TabSystem.list[sElementId];
    
    // Get all the Tab instances for this TabSystem.
    var tabs = ts.tabs;
    
    // Alert each Tab instance for this TabSystem.
    for(var i = 0, len = tabs.length; i < len; i++)
       alert(tabs[i]);
    		
  2. Or directly, like this:
    var tab = Tabs.list[sElementId];
    

What Can I Do With a Tab?

You can get a reference to the Tab's element, to the Tab's content element, and to the Tab's enclosing TabSystem instance. You can add Event Listeners to the tab.

A Tab instance has three properties. The example illustrates:


// The first tab instance for this TabSystem.
var tab = Tab.list[sElementId];
var el = tab.el; // the tab HTML element. 
var content = tab.content; // The tab's content HTML Element. 
var parentTabSystem = tab.ts; // The TabSystem instance that the tab belongs to. 

A Tab instance has two methods. The example illustrates:

var tabId = tab.toString(); // The tab's unique id. 
tab.addEventListener("onactivate", function() { alert(this); });

You can add any ant type of intrinsic event listener ("onmouseover", "onclick", et c) to a tab instance. You can also add an onactivate listener, as shown.

Next in this tutorial:

 

*AnimTree
*Tabs
*GlideMenus
*DragLib