1

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

Renan Araújo
  • 3,533
  • 11
  • 39
  • 49
Thalatta
  • 4,510
  • 10
  • 48
  • 79

1 Answers1

3

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

Simon Sarris
  • 62,212
  • 13
  • 141
  • 171
  • @Simon_Sarris Thank you. Not it only throws an error when I try to call `showContextMenu` on the `SeatingMapGraphicsRef`.In the following way: `SeatingMapGraphicsRef.toolManager.contextMenuTool.showContextMenu()` – Thalatta Sep 11 '15 at 02:46
  • which gives me this error: referring to that line: `Error: ContextMenuTool.showContextMenu:contextmenu value is not an instance of Adornment: undefined` – Thalatta Sep 11 '15 at 02:48
  • ah! it looks like I need to pass it an Adornment. Should I just pass the `GO` definition of the adornment above in to the function? – Thalatta Sep 11 '15 at 02:50
  • I try to passing `SeatingMapGraphicsRef.contextMenu` but I get `ContextMenuTool.showContextMenu:obj value is not an instance of GraphObject: undefined` – Thalatta Sep 11 '15 at 02:56