Dynamic Right Click Context Menu

Written by on February 22nd, 2007 in Ajax News.

Harel Malka needed a right click context menu for an application, and found that the offerings out there although provide a right click menu, do not actually provide any context. The menus are predefined in advance and dot really relate directly to what you clicked.

For example, If I right click a contact name link, I’d like my context menu to show me action links relating to that specific contact, such as: Email [contact email], Call [contact phone], Edit [Contact name] etc.

Harel created a library to do this for him called rightcontext.

Features

  • Menu items that link somewhere
  • Menu items that perform a custom javascript function
  • Menu items that display hardcoded text
  • Menu items that retrieve text via a remote ‘ajax’ call
  • Menu item separators
  • Image icons for menu items
  • Supports multiple different menus that can be called depending on the element clicked
  • All menu items can contain [tags] which are transformed at runtime to the values embedded in the clicked element
  • Conditional evaluation of menu items. An item can show or not show depending on a specified condition in the menu template (new in v0.2.3)
  • CSS based look and feel
  • Unobtrusive standalone javascript: no additional js framework required.

You simply define your menu ‘templates’ and add a ‘context’ attribute (and any additional custom ones you need) to each element you’d like to have a context menu:

HTML:

  1.  
  2. context="actionsMenu" attr1="name" attr2="email@email.com" …..
  3.  

Rightclick Context

Source: Ajaxian
Original Article: http://ajaxian.com/archives/dynamic-right-click-context-menu

Leave a Reply

You must be logged in to post a comment.



Site Navigation