Example: Adding A Context Menu To A TreeView (YUI Library)

When adding context menus to large data structures like a <table> or large list (<ol> or <ul>), it is recommended to bind a single YAHOO.widget.ContextMenu instance to the structure's root element, than to a set of its child nodes (<tr>s or <li>s). Doing so significantly improves the performance of a web page or application by reducing the number of "contextmenu" event handlers as well as the number of YAHOO.widget.ContextMenu instances in memory.

This example demonstrates how to display a context menu when the user clicks on any of the labels of the nodes in a YAHOO.widget.TreeView instance.

Please Note: Opera users will need to do the following to use this example: