Gallery

The Gallery is deprecated. No new Gallery components may be submitted, and modifying existing components is disabled. For more information please read the Gallery Deprecation blog post. This is a static snapshot of the Gallery for archive purposes.

Todd Smith

YUI Contributor

This module includes a Y.View class extension that attaches to an existing "trigger" Node and uses event delegation to listen for "contextmenu" requests (i.e. right-click). When the context menu is invoked, a Y.Overlay object is rendered and displayed that includes user-defined menu items that are related to the context where the menu was invoked. This view utilizes several attributes and fires several events that users can listen to in order to take specific actions based on the "trigger target" node.

A natural application for this ContextMenu View is for a DataTable.

This image shows a DataTable which uses two Y.ContextMenuView's, one is attached to the TBODY as the "trigger" node, with the "target" as the individual TR's. The other view is attached to the DT's THEAD as the "trigger" node, with the "target" being the TH nodes.

A few CSS classes are used to track the context menu overlay and each individual menu item in the menu.