JsPlumb connect not using existing source/target endpoint style

522 views Asked by At

Firstly, there are two nodes in the canvas, and some endpoint styles has been applied. If I drag a connection between them, all styles can be kept. That's OK. But when using jsPlumb connection method, it will import default endpoint style rather than the given styles. How can I avoid this?

1) new connection generated by user drag event from source to target. enter image description here

2) using jsplumb.connect(), while the method using default endpoint styles. enter image description here

some javascript code is here:

    var connectorPaintStyle = {
        strokeWidth: 2,
        stroke: "#61B7CF",
        joinstyle: "round",
        outlineStroke: "white",
        outlineWidth: 2
    };

    var conn = jsptoolkit.jspinstance.connect({
        source: line.sdata.sourceId,
        target: line.sdata.targetId,
        anchors: line.sdata.anchors,
        paintStyle: connectorPaintStyle,
        connector: ["Flowchart", { stub: [2, 2], gap: 1, cornerRadius: 5, alwaysRespectStubs: true }],
    });
1

There are 1 answers

0
Bes Ley On BEST ANSWER

The correct way is to use uuids array rather than source and target. I have modified the connect method code:

var conn = jsptoolkit.jspinstance.connect({
        uuids: [line.sdata.sourceId + "RightMiddle", line.sdata.targetId + "LeftMiddle"],
        anchors: line.sdata.anchors,
    });

There is a similar question: Jsplumb add connection programatically using endpoints