YUI recommends YUI3.
YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.
This documentation is no longer maintained.
In this simple example you see the default presentation for the TreeView Control. Click on labels or on the expand/collapse icons for each node to interact with the TreeView Control.
In this simple example for the TreeView Control, we begin with a target <div>
on the page; that target <div>
is where our tree will be built.
We can now instantiate our TreeView and populate its nodes.
Once you have a tree in place, and even before you call its draw()
method, you can begin subscribing to the events in its API. For example, if you'd like to execute a function each time a node is collapsed, you would do the following:
For the sake of this example, we've elaborated on the code above and used loops and some random number logic to build out a larger tree. We've stubbed out some additional event handlers that you might want to experiment with. We've also wrapped the entire snippet in an anonymous function. Here's the full source of the JavaScript we're using to generate the TreeView:
Use this simple example to get started in your explorations of the TreeView Control, then move on to the more complex examples that explore additional features the control offers.
Note: Logging and debugging is currently turned off for this example.
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.
Copyright © 2013 Yahoo! Inc. All rights reserved.