2014-01-10 67 views
1

假設我有一個包含4個端點的元素,每個端點都有一個連接。我需要顯示端點標籤中的所有連接,並通過單擊它的名稱來刪除所有連接。 jsPlumb是否有這種能力?或者我該怎麼做? enter image description hereJsPlumb端點覆蓋

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(); 
    }); 
+0

jsPlumb具有連接標籤但沒有端點標籤。你想要單擊或雙擊刪除連接嗎?如果是的話,這是可能的。 – MrNobody

+0

我可以從元素中獲取所有端點。每個端點都有一個連接。現在我需要在端點覆蓋圖(標籤)中顯示它(假設有4個連接),並通過點擊將它刪除。 – MaxD

+0

對不起,我沒有得到你,你可以想象它併發布圖像。 – MrNobody

回答

1

試試這個。創建新連接時,綁定事件以刪除連接:

jsPlumb.bind("jsPlumbConnection", function(ci) { 
      ci.connection.bind("click",function(con){ 
       jsPlumb.detach(con); 
      }); 
     }); 

讓我知道它是否適用於您。

+0

Pruthvi Bharadwaj,謝謝!但你的例子不適用於我的情況。一個元素可以有很多端點,用戶只能看到最後一個端點(請參閱要求)。這就是爲什麼我需要一些彈出或標籤來顯示所有連接的元素,並刪除選定的。 – MaxD