假设我有一个有4个端点的元素,每个端点都有一个连接。我需要显示端点标签中的所有连接,并通过单击其名称删除任何连接。jsPlumb开箱即有这个能力吗?或者我该怎么做呢?

sourceEndpoint = jsPlumb.addEndpoint($(requirementSelector), {overlays: removeLabel, maxConnections: -1, endpoint: ["Dot", { radius: 4}], anchors: ["RightMiddle", "LeftMiddle"]});
targetEndpoint = jsPlumb.addEndpoint($(solutionSelector), {overlays: removeLabel,maxConnections: -1, endpoint: ["Dot", { radius: 4}], anchors: ["RightMiddle", "LeftMiddle"]});
jsPlumb.connect({
source: sourceEndpoint,
target: targetEndpoint
});
targetEndpoint.bind("click", function(endpoint) {
var elementEndpoints = jsPlumb.selectEndpoints({element: endpoint.elementId});
var ids="<div style='border: 2px solid black; padding: 5px; background-color: #ffffff'; z-index:10;>";
elementEndpoints.each(function(ep){
ids += "<p ng-click='clicked()'>Remove - " + ep.id + "</p>"
});
ids += "</div>";
endpoint.setLabel(ids);
endpoint.showOverlay();
});发布于 2014-01-10 19:21:01
尝尝这个。每次创建新连接时,绑定一个事件以删除该连接:
jsPlumb.bind("jsPlumbConnection", function(ci) {
ci.connection.bind("click",function(con){
jsPlumb.detach(con);
});
});让我知道它是否适用于您。
https://stackoverflow.com/questions/21042274
复制相似问题