1

我正在使用 JS GraphLib Draw2D 并且在 onContextMenu 事件中我附加了 jQuery-Menu 并且它出现但没有关闭!

当我设置自动隐藏或事件时,我得到了 Uncaught RangeError: Maximum call stack size exceeded。

代码:

var LabelRectangle = draw2d.shape.basic.Rectangle.extend({

init: function () {
    this._super(200, 30);

    // Create any Draw2D figure as decoration for the connection
    //
    this.label = new draw2d.shape.basic.Label("A new Label");
    this.label.setColor("#EEC422");
    this.label.setFontColor("#0d0d0d");
    this.label.setBold = true;
    this.label.setFontFamily("Arial");
    this.label.setFontSize(14);
    this.label.setBackgroundColor("#EEC422");
    this.setBackgroundColor("#EEC422");
    this.createPort("output");


    // add the new decoration to the connection with a position locator.
    //
    this.addFigure(this.label, new draw2d.layout.locator.CenterLocator(this));

    this.label.installEditor(new draw2d.ui.LabelInplaceEditor());
},
onContextMenu: function (x, y) {
            var shape = this.shape[0];
            $(shape).attr('id', this.getId());
            var id = "#" + $(shape).attr('id');
            $.contextMenu({
                selector: id,
                autoHide: true,
                events:
                                    {
                                        hide: function () {
                                            $.contextMenu('destroy');
                                        }
                                    },
                callback: $.proxy(function (key, options) {
                    switch (key) {
                        case "red":
                            this.setColor("ff0000");
                            break;
                        case "green":
                            this.setColor("00ff00");
                            break;
                        case "blue":
                            this.setColor("0000ff");
                            break;
                        case "delete":
                           //  without undo/redo support
                           //  this.getCanvas().removeFigure(this);

                           //  with undo/redo support
                            var cmd = new draw2d.command.CommandDelete(this);
                            this.getCanvas().getCommandStack().execute(cmd);

                        default:
                            break;
                    }

                }, this),
                x: x,
                y: y,
                items:
                        {
                            "red": { name: "Red" }, // callback: function () { return true; } },
                            "green": { name: "Green" },
                            "blue": { name: "Blue" },
                            "delete": { name: "Delete" }
                        }
            });
}

});

4

1 回答 1

1

我删除了对引导库的引用,现在运行良好。

于 2013-06-17T19:12:30.280 回答