要操縱標記爲的圖,我想我需要在jsPlumb連接的每個標籤上添加一個附加屬性。例如,當我點擊連接標籤時,即使源標籤點和目標標籤點可以從標籤標識(或屬性)中推導出來,我也無法知道哪種類型的標籤點擊過。確定在jsPlumb中點擊了哪個標籤
僅僅改變jsPlumb圖形是不夠的,因爲存在由jsPlumb圖形表示的未解壓數據結構。使用jsPlumb.ready和jsPlumb.bind的代碼已經很好地實現並且工作正常。
var newConn = jsPlumb.connect({ source: from, target: to,
endpoint: epStyle, detachable: false,
anchor: "Continuous", connector: ["StateMachine", { curviness: 20}],
paintStyle: lineSt, hoverPaintStyle: lineHoverSt,
overlays: [
["Arrow", { width: 10, length: 10, foldback: 1, location: 0.25,
id: "arrow_" + from + to + 1}],
["Arrow", { width: 10, length: 10, foldback: 1, location: 0.75,
id: "arrow_" + from + to + 2}],
["Label",
{ label: relation.name, id: "label_" + from + to + rel_id, cssClass: "edgeLabel"}
// Any additional property here?
]
]
});
//Or add property here?
newConn.type = SOME_EDGE_TYPE;
jsPlumb.ready(function() {
jsPlumb.bind("click", function (c) {
jsPlumb.detach(c);
});
jsPlumb.bind("beforeDetach", function (conn) {
return confirm(
"Are you sure you want to disconnect ["
+ conn.sourceId + "=>" + conn.targetId + "]?");
});
});
那麼你想在點擊標籤時獲得端點(邊緣)嗎? – MrNobody
...和「邊緣類型」(如標記圖中所示) –
如果jsPlumb.connect返回邊(連接)對象,它可能會好得多。然後可以像下面這樣引用端點和附加的邊界類型:var newConn = jsPlumb.connect(...); newConn.type(...) –