Dashboard > Fluid > ... > Fearless JavaScript 1.0 > Example of jQuery UI Tabs Progressive Enhancement
Example of jQuery UI Tabs Progressive Enhancement
Added by Colin Clark, last edited by Colin Clark on Apr 20, 2008
Labels: 
(None)


The jQuery UI Tabs widget is a great example of how a widget's API can encourage progressive enhancement from the start. While there's still a lot of room for growth in this widget, I really like how its author, Klaus Hartl, has built the widget with a markup-driven approach. In my mind, this is much more successful than a JSON-based approach because it uses HTML markup as both a way of specifying data for the widget and as a source of graceful degradation.

<div id="tabsAndPanels">

    <!-- The tabs themselves are marked up here as a simple unordered list with anchors for each tab title. -->
    <ul id="tabs">
        <li id="catsTab"><a href="#catsPanel" tabindex="-1"><span>Cats</span></a></li>
        <li id="dogsTab"><a href="#dogsPanel" tabindex="-1"><span>Dogs</span></a></li>
        <li id="hamstersTab"><a href="#hamstersPanel" tabindex="-1"><span>Hamsters</span></a></li>
        <li id="alligatorsTab"><a href="#alligatorsPanel" tabindex="-1"><span>Alligators</span></a></li>
    </ul>

    <!-- The panels associated with each tab are marked up as divs -->
    <div id="panels">
      <div id="catsPanel">
        Cats meow.
      </div>
      <div id="dogsPanel">
        Dogs bark.
      </div>
      <div id="hamstersPanel">
        Hamsters wheel.
      </div>
      <div id="alligatorsPanel">
        Alligators bite.
      </div>
    </div>

 </div>
 
 <script type="text/javascript">
    jQuery(document).ready(function(){ 
       jQuery("#example > ul").tabs();
    });
 </script>

Site running on a free Atlassian Confluence Open Source Project License granted to The FLUID Project. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5 Build:#805 Apr 26, 2007) - Bug/feature request - Contact Administrators