Search code examples
jsplumb

Connecting existing addEndpoint() to existing makeTarget() in jsPlumb


I have seen elsewhere the following technique for attaching existing endpoints. This works fine when both the source and target are created using addEndpoint()

var e0 = jsPlumb.addEndpoint("container0",{uuid:"ep1"}),  //set your own uuid for endpoint for later access.
var e1 = jsPlumb.addEndpoint("container1",{uuid:"ep2"});  
jsPlumb.connect({ uuids:[e1.getUuid(),e2.getUudi()] }); // (or) jsPlumb.connect({ uuids:["ep1","ep2"] });

However, in my case I need to join and endpoint to a target created using makeTarget()

var e0 = jsPlumb.addEndpoint("container0",{uuid:"ep1"}),  //set your own uuid for endpoint for later access.
var e1 = jsPlumb.makeTarget("container1",{uuid:"ep2"});  
jsPlumb.connect({ uuids:[e1.getUuid(),e2.getUudi()] }); // (or) jsPlumb.connect({ uuids:["ep1","ep2"] });

However this does not work and the returned results from makeTarget() does not even have a getUuid() method.

How can I achieve this?


Solution

  • This should work:

    jsPlumb.connect({
        source: sourceUUID,
        target: targetID,
        uuids: [sourceUUID, targetID],
        editable: true
    });