【发布时间】:2015-10-01 13:07:30
【问题描述】:
connectionMoved事件触发时似乎没有connectionDetached事件。
因此,当您移动连接时,它会创建一个新连接并保留旧连接。
我想删除第一个连接。最好在创建第二个之前(不要超过 maxConnections)。这可能吗?
【问题讨论】:
标签: events connection move jsplumb detach
connectionMoved事件触发时似乎没有connectionDetached事件。
因此,当您移动连接时,它会创建一个新连接并保留旧连接。
我想删除第一个连接。最好在创建第二个之前(不要超过 maxConnections)。这可能吗?
【问题讨论】:
标签: events connection move jsplumb detach
Simon 指出:“移动连接时,jsPlumb 不会创建新连接并删除旧连接。它只是更改其端点的元素。”
问题就是这样解决的:
jsPlumbMain.bind("connection", function (info, originalEvent ) {
if (originalEvent == null) {
return;
}
if (moving) {
// Remove old connection from DB
removeItem(info.connection .ourId);
}
currentConnection = info.connection;
var hoverPaintStyle = {strokeStyle: "#CC3333"};
currentConnection.setHoverPaintStyle(hoverPaintStyle);
var src = info.sourceEndpoint;
var dst = info.targetEndpoint;
createConnection(src.ourId, dst.ourId);
moving = false;
});
jsPlumbMain.bind("connectionDetached", function (info) {
var conn = info.connection;
removeItem(conn.ourId);
moving = false;
});
jsPlumbMain.bind("connectionMoved", function (info, originalEvent) {
alert('moved');
moving = true;
});
【讨论】: