Search code examples
javascriptjqueryjsplumb

JSplumb - get connection to a specific endpoint


I have elements that have several endpoints on them.

I can get all the connections attached to a particular element:

// plumber is my JSPlumb instance object
connSet = plumber.getConnections({target:eltID});

The problem is, how do I find connections attached to one particular endPoint?


Solution

  • To filter information by specific end point, you need first to make sure that the end points have been assigned a uuid:

    // plumber is my JSPlumb instance object
    var properties = {uuid: "elt-in-1"}
    plumber.addEndpoint(element, properties, connectStyle);
    

    Once a uuid is assigned the connections can be filtered according to it:

    // getConnections still has no filter by endPoint, AFAIK
    connSet = plumber.getConnections({target:eltID});
    epSubSet = connSet.filter(conn=>(conn.endpoints[1].getUuid()=="elt-in-1"))