This example demonstates how to use the ContextMenu widget to add a context menu to a YUI TreeView control. The context menu allows the user to add, edit and remove items from a TreeView instance.
Please Note: Opera users will need to do the following to use this example:
When adding context menus to large data structures like a
<table> or large list (
<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 (
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.
Begin by creating a TreeView instance. Next, create an object that maps HTML ids to their corresponding TextNode instances. As each TextNode instance is added to the TreeView, store a reference to it in the map.
Copyright © 2009 Yahoo! Inc. All rights reserved.