jsPlumb:connectionMoved事件触发时没有connectionDetached事件
问题描述:
当connectionMoved事件触发时,似乎没有connectionDetached事件。jsPlumb:connectionMoved事件触发时没有connectionDetached事件
因此,当您移动连接时,它会创建一个新连接并保留旧连接。
我想删除第一个连接。最好在第二个创建之前(不要超过maxConnections)。这可能吗?
答
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;
});