Question

I am using this code to connect a single object one another object and this works fine. Could anybody help me to modify this to link a single object to multiple objects.

var start = 'logo';
var end = 'link';    
jsPlumb.connect({
    source:start,
    target:end,
    connector: [ "Flowchart", {cornerRadius:1} ],
    paintStyle:{
        lineWidth:5,
        strokeStyle:'#3E2522' },
    anchors: [[1.02, 0.5, 0, 1], [-0.02, 0.5, 0, 0]],
    endpointStyle: { radius:0.5 }
});
Was it helpful?

Solution

Store all the id's of the target elements in an array and then you can loop the above code for your result:

var start = 'logo';
var end = ['link1','link2','link3',....];    

for(var i=0;i<end.length;i++){
    jsPlumb.connect({
        source:start,
        target:end[i],
        connector: [ "Flowchart", {cornerRadius:1} ],
        paintStyle:{
            lineWidth:5, strokeStyle:'#3E2522' },
        anchors: [[1.02, 0.5, 0, 1], [-0.02, 0.5, 0, 0]],
        endpointStyle: { radius:0.5 }
    })
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top