JavaScript
  Home arrow JavaScript arrow Page 3 - Using Unique and Toggle in a TreeView jQuery Hierarchical Navigation System
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
JAVASCRIPT

Using Unique and Toggle in a TreeView jQuery Hierarchical Navigation System
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 3
    2009-05-11


    Table of Contents:
  • Using Unique and Toggle in a TreeView jQuery Hierarchical Navigation System
  • A quick review of the animate argument
  • Restricting the opening of a tree's branches with the unique option
  • Using the toggle parameter to trigger callback functions

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Using Unique and Toggle in a TreeView jQuery Hierarchical Navigation System - Restricting the opening of a tree's branches with the unique option
    ( Page 3 of 4 )

    As I stated in the previous section, the "TreeView" plug-on provides a parameter called "unique," which can be useful in a number of ways -- for instance, where you wish that users of your web site browse individually categories of a hierarchical menu. But now that you have a vague idea of how this option works, it's time to see how it can be utilized within the context of a concrete example. Take a look at the following one, to grasp more clearly the use of the "unique" argument:

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <title>Example on jQuery TreeView (using the unique option)</title>

    <link rel="stylesheet" href="jquery.treeview.css" type="text/css" />

    <script type="text/javascript" src="jquery.js"></script>

    <script type="text/javascript" src="jquery.treeview.js"></script>

    <script>

    // build treeview after web page has been loaded

    $(document).ready(function(){

    $("#menu").treeview({

    unique: true

    });

    });

    </script>

    </head>

    <body>

    <ul id="menu">

    <li>Link 1

    <ul>

    <li>Sub link 1</li>

    <li>Sub link 2</li>

    <li>Sub link 3</li>

    <li>Sub link 4</li>

    <li>Sub link 5</li>

    </ul>

    </li>

    <li>Link 2

    <ul>

    <li>Sub link 1</li>

    <li>Sub link 2</li>

    <li>Sub link 3</li>

    <li>Sub link 4</li>

    <li>Sub link 5</li>

    </ul>

    </li>

    <li>Link 3

    <ul>

    <li>Sub link 1</li>

    <li>Sub link 2</li>

    <li>Sub link 3</li>

    <li>Sub link 4</li>

    <li>Sub link 5</li>

    </ul>

    </li>

    <li>Link 4

    <ul>

    <li>Sub link 1</li>

    <li>Sub link 2</li>

    <li>Sub link 3</li>

    <li>Sub link 4</li>

    <li>Sub link 5</li>

    </ul>

    </li>

    <li>Link 5

    <ul>

    <li>Sub link 1</li>

    <li>Sub link 2</li>

    <li>Sub link 3</li>

    <li>Sub link 4</li>

    <li>Sub link 5</li>

    </ul>

    </li>

    </ul>

    </body>

    </html>

     

    From the previous code sample, it's clear to see how simple it is to restrict the behavior of a targeted tree to permit only one branch to be expanded at a time. Naturally, the best way to understand how the "unique" argument does its business is for you to try out this example on your own browser, so I encourage you to do that as soon as you can. You'll be surprised to see how smoothly it functions. 

    Since at this stage you hopefully grasped the logic that stands behind using the "unique" option, it's time to continue exploring other capabilities offered by the "TreeView" plug-in. Therefore, in the last section of this tutorial I'm going to discuss the use of the "toggle" parameter, which can be used for triggering callback functions when branches of a tree are expanded and collapsed. 

    This topic will be discussed in detail in the following segment. Thus, to learn more about it, click on the link below and read the next few lines.  



     
     
    >>> More JavaScript Articles          >>> More By Alejandro Gervasio
     

       

    JAVASCRIPT ARTICLES

    - Introduction to JavaScript
    - Adding Elements to a Tree with TreeView jQue...
    - Using the Persist Argument in a TreeView jQu...
    - Using Unique and Toggle in a TreeView jQuery...
    - Using Event Delegation for Mouseover Events ...
    - Using the Animate Option in a Treeview jQuer...
    - Using HTML Lists with Event Delegation in Ja...
    - Opened and Closed Branches on a TreeView jQu...
    - Mouseover Events and Event Delegation in Jav...
    - Creating a TreeView JQuery Hierarchical Navi...
    - Event Delegation in JavaScript
    - A Look at the New YUI Carousel Control
    - Working with Draggable Elements and Transpar...
    - Displaying Pinned Handles with Resizable Con...
    - Building Resizable Containers with the Ext J...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek