1
Я использую JS GraphLib Draw2D и on onContextMenu. Я добавляю jQuery-Menu и появляется, но не закрывается!Я не могу закрыть jQuery-ContextMenu с помощью Draw2D touch
Когда я устанавливаю autoHide или события, я получаю Uncaught RangeError: максимальный размер стека вызовов превышен.
Код:
вар 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" }
}
});
}
});