Search code examples
javascriptjsplumb

Auto Connecting with jsPlumb


Hello StackOverflow community, this is my first post, so please be gentle, since I don't know the etiquette here yet.
Anyways, can someone help me auto connect with jsPlumb? I just can't figure out how to do it, using the styles in addEndpoint function. Hope there are some clever people, that are willing to help me & figure it out. jsFiddle


Solution

  • You need to add uuids for each endpoints. Using your current setup:

    function addEndpoints(id,target,source) {
    
        // Setting Source-/Startpoint Style
        var sourceEndpoint = {
            endpoint:"Dot",
            isSource:true,
            ...
            uuid: "xxx0"
        },      
    
        // Setting Targetpoint Style
        targetEndpoint = {
            endpoint: ["Rectangle", {width:13, height:13}], 
            isTarget:true,      
            ...
            uuid: "xxx1"
        };  
    
        ...
    
    }
    

    and connect them in your init functions:

    jsPlumb.connect({ uuids:["xxx0","xxx1"] });