Reputation: 4578
I have the following definition for a contextMenu
on my Go diagram
SeatingMapGraphicsRef.contextMenu =
$(go.Adornment, "Vertical",
// no binding, always visible button:
$("ContextMenuButton",
$(go.TextBlock, "Hold Seats"),
{ click: function(e, obj) {
holdSeatsInDragSelect();
} }),
$("ContextMenuButton",
$(go.TextBlock, "Select Seats"),
{ click: function(e, obj) {
} }),
$("ContextMenuButton",
$(go.TextBlock, "Lock Seats"),
{ click: function(e, obj) {
} }),
$("ContextMenuButton",
$(go.TextBlock, "Cancel"),
{ click: function(e, obj) {
var diagram = e.diagram;
diagram.hideContextMenu();
} })
);
However when I write this, I get the following error:
Error: Diagram.contextMenu value is not an instance of Adornment
How exactly is this the case?
Here is my definition of SeatingMapGraphicsRef
function generateMap() {
SeatingMapGraphicsRef =
GO(go.Diagram, "mapBodyDiv", // the DIV HTML element
{
initialContentAlignment: go.Spot.Center,
initialAutoScale:go.Diagram.Uniform,
"toolManager.mouseWheelBehavior": go.ToolManager.WheelZoom
});
And finally here is the reference page on ContextMenus from which I took the contextMenu definition on a diagram
level.
http://gojs.net/latest/intro/contextMenus.html
Upvotes: 1
Views: 591
Reputation: 63872
Because you started to use:
var GO = go.GraphObject.make;
Instead of the (common in the samples):
var $ = go.GraphObject.make;
Presumably because you're using jQuery too.
It will probably work if you change all the $
to GO
in your Adornment definition
Upvotes: 3