Search code examples
javascriptjsplumb

JSPlumb Endpoint Multiple Connections


i have some div elements which i want to connect them via JSPlumb Community Edition. i have these line of codes in javascript:

$("#create_item").click(function() {
    var $i = "item" + counter;
    var $txt = "Create " + counter;
    var $div = $("<div>", {id: $i, class: "box create", text: $txt});
    $(".container").append($div);
    counter++;
    jsPlumb.ready(function() {
        jsPlumb.draggable($i, {containment:"parent"});
        jsPlumb.addEndpoint($i, { 
            anchor:"Right" },
            sourceEndpointOptions);
    });
});

$("#dispose_item").click(function() {
    var $i = "item" + counter;
    var $txt = "Dispose " + counter;
    var $div = $("<div>", {id: $i, class: "box dispose", text: $txt});
    $(".container").append($div);
    counter++;
    jsPlumb.ready(function() {
        jsPlumb.draggable($i, {containment:"parent"});
        jsPlumb.addEndpoint($i, { 
            anchor:"Left" },
            targetEndpointOptions);
    });
});

var sourceEndpointOptions = {
    endpoint:"Dot",
    paintStyle:{ width:15, height:15, fillStyle:'#666' },
    isSource:true,
    connectorStyle : { strokeStyle:"#666" },
    isTarget:false
};

var targetEndpointOptions = {
    endpoint:"Dot",
    paintStyle:{ width:15, height:15, fillStyle:'#460CE8' },
    isSource:false,
    connectorStyle : { strokeStyle:"#460CE8" },
    isTarget:true
};

and what i want to do is making two #create_tem and one #dispose_item in runtime and connect the the two source endpoint to the target endpoint, but when i connect one source to the target, the target won't accept the second source. how can i do this?


Solution

  • i was missing maxConnections:-1 in the End Point Options!