如何从单个起点连接多个端点?

时间:2016-10-13 14:19:44

标签: javascript jquery jsplumb

以下代码使我能够将一个起始点连接到端点A或端点B,但不能同时连接两者!有人可以帮我修改这个,所以可以链接到两个端点吗? Here's a fiddle to illustrate my point ))

$(function() {

    jsPlumb.ready(function() {
        var jsp = jsPlumb.getInstance();
        jsp.draggable($("#start"));
        jsp.draggable($("#end_A"));
        jsp.draggable($("#end_B"));

        var endpoint = jsp.addEndpoint($("#start"), {
            isSource:true
        });

        jsp.addEndpoint($("#end_A"), {
            isTarget:true
        }); 

        var endpoint = jsp.addEndpoint($("#start"), {
            isSource:true
        });

        jsp.addEndpoint($("#end_B"), {
            isTarget:true
        }); 

        $("#dragbutton").bind("mousedown", function(e) {

            $(document).bind("mousemove.adjust", function(e) {

                var left = e.offsetX;
                var top = e.offsetY;
                $(endpoint.canvas).css({"left":left, "top":top});
                $(document).unbind("mousemove.adjust");
            });

            $(endpoint.canvas).trigger(e)
        })           

    })       

})

1 个答案:

答案 0 :(得分:0)

使用 maxConnections 属性。

maxConnections: -1 // unlimited connections
maxConnections: 1 // only one connection