Creating a jquery context menu on right-click

Hello,

Does anyone have an example of creating a jquery context menu on right clicking of a node?

Thanks!

This does not use jQuery, but have you seen HTML Context Menu, which demonstrates two different kinds of HTML context menus?

Yes, I have seen the example. In the example, it reads “// This would be easier with a library like jQuery,”. I was using jquery for another context menu on my page so I thought to keep my code clean it would be nice to us the same kind of context window.


So far I have:

var graphObjectMake = go.GraphObject.make;

Diagram.addDiagramListener(“ObjectContextClicked”,
function(e,t) {
var mousePt = Diagram.lastInput.viewPoint;
var part = e.subject.part;
if (!(part instanceof go.Link))
{
$(’#ContextMenuDiv’).menu(‘show’,{
left: mousePt.x,
top: mousePt.y
});
}
}
);




Append
Remove
Edit
As always, Thanks for the speedy response walter!

The following is the code to open a jquery window by right clicking anywhere on the document:

$(function(){
$(document).bind(‘contextmenu’,function(e){
e.preventDefault();
$(’#ContextMenuDiv’).menu(‘show’, {
left: e.pageX,
top: e.pageY
});
});
});

Append
Remove
Edit
Hope this helps anyone who is trying to do this.