O'Reilly logo

YUI 2.8 Learning the Library by Dan Wellman, Daniel Barreiro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Planting the seed

There are three ways to build a tree; we can point to existing HTML consisting of a series of nested ordered or unordered lists (<ol> or <ul>) and TreeView will enhance it. We can have a literal object defining the tree, or we can create and append one node at a time.

If we had the following HTML:

<div id="markup">
<ul>
<li class="expanded">List 0
<ul>
<li class="expanded">List 0-0
<ul>
<li>item 0-0-0</li>
<li><a target="_new"
href="http://www.elsewhere.com"
title="go elsewhere">elsewhere</a></li>
</ul>
</li>
</ul>
</li>
<li>List 1
<ul>
<li>List 1-0
<ul>
<li>02/01/2009</li>
<li>item 1-1-0</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>

This is all the code we would need to enhance this static HTML into a full TreeView:

<script type="text/javascript"> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required