Diagram.contextMenu值不是Adornment的实例

时间:2015-09-11 01:41:12

标签: javascript gojs adornment

我在Go contextMenu

上有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();
    } })
);

但是当我写这篇文章时,我收到以下错误:

Error: Diagram.contextMenu value is not an instance of Adornment

情况究竟如何?

以下是我对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
        });

最后,这是ContextMenus上的参考页面,我在diagram级别上从中获取了contextMenu定义。

http://gojs.net/latest/intro/contextMenus.html

1 个答案:

答案 0 :(得分:3)

因为你开始使用:

var GO = go.GraphObject.make;

而不是(样本中常见的):

var $ = go.GraphObject.make;

大概是因为你也在使用jQuery。

如果您在装饰品定义中将所有$更改为GO,则可能会有效