Benster, >Im new to jquery and im struggling with hopefully a simple question! > >Im using the Context Menu plugin - >http://www.trendskitchens.co.nz/jquery/contextmenu/ >which allows you to generate a right-click menu. All works fine, >however im now trying to pass in the id of the item that has been >clicked upon. > >Im listing several images on a page, and offering the right-click menu >for each. I need to pass in the id of the image which has been >clicked. Each image has a div with a unique id. > >The documentation mentions "bindings" which i think is what im after, >but have no idea how to display the function pairs. Here is the >description from the docs - > >An object containing "id":function pairs. The supplied function is the >action to be performed when the associated item is clicked. The >element that triggered the current menu is passed to this handler as >the first parameter. > >Can anyone advise me on how to proceed?
It's been a while since I've used that plug-in for a project, but it is the "bindings" option you're looking for: $("#attachTo").contextMenu("#menuDiv", { bindings : { "a.cm_item" : function (trigger, target){ // "trigger" is the "#attachTo" element console.log(trigger); // "target" should be the "a.cm_item" element console.log(target); } } }); The above should attach a click event to every <a class="cm_item" /> tag found in the context menu. The "target" argument should be a reference to this DOM element. -Dan