如何从一个起点连接多个端点?
How can I connect multiple endpoints from a single startpoint?
下面的代码使我能够将一个起点连接到端点 A 或端点 B,但不能同时连接到两者!谁能帮我修改一下,这样就可以 link 到两个端点?
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)
})
})
})
使用 maxConnections 属性.
maxConnections: -1 // unlimited connections
maxConnections: 1 // only one connection
下面的代码使我能够将一个起点连接到端点 A 或端点 B,但不能同时连接到两者!谁能帮我修改一下,这样就可以 link 到两个端点?
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)
})
})
})
使用 maxConnections 属性.
maxConnections: -1 // unlimited connections
maxConnections: 1 // only one connection