tags:

views:

25

answers:

1

I am looking for an easy way to select an option from a select list and be able to perform a number of actions on that option. One of the main operations is to edit the option. I would like to implement a context type menu by right clicking the option and then perform the action.

Does anyone know how to capture a right click on a select box option with jQuery?

I would like to use: http://abeautifulsite.net/blog/2008/09/jquery-context-menu-plugin/

Thanks!!!

+1  A: 

The event has a "which" property that hols the "id" of the button pressed. You should use it with the "mousedown" event to prevent the browser's context menu to appear.

$("#selectBoxID").mousedown(function(e) {
    if (e.which == 1) {
        /*  left click action */
    }
    else if (e.which == 2) {
        /*  middle click action */
    }
    else if (e.which == 3) {
        /*  right click action */
    }
});
Esteban Petrovich
I have the events wired to disable the browser context. If I hook the plugin up to the select list itself then I get the context menu I want but if bound to the list option such as $("#selectlist option").contextMenu then I do not get the context menu.
Tuck