YUI Library Home

YUI Library Examples: TabView Control: Getting Content from an External Source

TabView Control: Getting Content from an External Source

This demonstrates how to load Tab content from an external data source.

Browser News

Loading TabView from an External Data Source

The YUI TabView provides a built-in way to load external data.

Because our content depends on JavaScript, in this case we will build our TabView entirely from script. First create a container to insert our new TabView into. This can be any existing element on the page, including the <body>, but for this example, we will create a <div> called container:

Next we will create a TabView instance, omitting the element argument, which signals the constructor to create the TabView container:

Next we add tabs to our TabView, including the label and a dataSrcpointing to the content, setting the default selected tab to "active". To minimize the number of requests, we will set each cacheData for each Tab.

All that is left is to append our new TabView to our container:

This is a basic example of how to load content from an external source into a TabView widget.

Configuration for This Example

You can load the necessary JavaScript and CSS for this example from Yahoo's servers. Click here to load the YUI Dependency Configurator with all of this example's dependencies preconfigured.

Copyright © 2009 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings