我试图创建动态endpoint,作为我的连接和运行问题的覆盖。我试图模拟这个人在SO上有什么:
jsPlumb连接自定义覆盖-endpoint未移动
然而,当我达到这一点时,无论我尝试做什么:
var overlay_div = $(connection.overlays[0].canvas);
我无法识别连接。我尝试将此逻辑放入绑定连接中,但在尝试建立连接覆盖时,这也不起作用。在这方面提供任何帮助都会非常有帮助。
http://jsfiddle.net/nitincool4urchat/c3b514wf/14/
首先,创建自定义元素作为覆盖
其次,确保这些元素具有唯一的ID
第三,绑定到连接
事件,在这些自定义覆盖上创建endpoint。
jsPlumb.ready(function() {
// setup some defaults for jsPlumb.
instance = jsPlumb.getInstance({
Endpoint : ["Dot", {radius:2}],
HoverPaintStyle : {strokeStyle:"#1e8151", lineWidth:4 },
ConnectionOverlays : [
[ "Arrow", {
location:1,
id:"arrow",
length:14,
foldback:0.8
}]
,["Custom", {
create: function(component) {
return connectionNode();
},
location:0.5
}]
//,[ "Label", { label:"Connect To", id:"label", cssClass:"aLabel" }]
],
Container: "flowchart-demo"
});
var relationEndpoint = {
endpoint: ["Dot", { radius: 2 }],
isSource: true,
connector: ["Flowchart", { stub: [40, 60], cornerRadius: 5, alwaysRespectStubs: true }],
connectorStyle: { strokeStyle: "#5c96bc", lineWidth: 4, outlineColor: "transparent", outlineWidth: 4 },
maxConnections: 5,
onMaxConnections: function (info, e) {
alert("Maximum connections (" + info.maxConnections + ") reached");
},
isTarget: true,
dropOptions: {
tolerance: "touch",
hoverClass: "dropHover",
activeClass: "dragActive"
},
beforeDetach: function (conn) {
return confirm("Detach connection?");
}
};
function connectionNode() {
//var overlay_div = $(connection.ConnectionOverlays[0].canvas);
//jsPlumb.addEndpoint({ anchor: ["Perimeter", { shape: "Rectangle" }] }, relationEndpoint);
return $("<div>Custom</div>",{id:Date.now()}).css({border:'1px solid black',background:'green'});
}
var windows = jsPlumb.getSelector(".flowchart-demo .window");
instance.draggable(windows);
instance.bind("connection", function(info) {
console.dir(info.connection);
console.dir(info.connection.getOverlays());
console.dir(info.connection.getOverlays()[1].canvas);
var overlay_div = $(info.connection.getOverlays()[1].canvas);
jsPlumb.addEndpoint(overlay_div,{ anchor: ["Perimeter", { shape: "Rectangle" }] }, relationEndpoint);
});
// suspend drawing and initialise.
instance.doWhileSuspended(function() {
var isFilterSupported = instance.isDragFilterSupported();
// make each ".ep" div a source and give it some parameters to work with. here we tell it
// to use a Continuous anchor and the StateMachine connectors, and also we give it the
// connector's paint style. note that in this demo the strokeStyle is dynamically generated,
// which prevents us from just setting a jsPlumb.Defaults.PaintStyle. but that is what i
// would recommend you do. Note also here that we use the 'filter' option to tell jsPlumb
// which parts of the element should actually respond to a drag start.
// here we test the capabilities of the library, to see if we
// can provide a `filter` (our preference, support by vanilla
// jsPlumb and the jQuery version), or if that is not supported,
// a `parent` (YUI and MooTools). I want to make it perfectly
// clear that `filter` is better. Use filter when you can.
if (isFilterSupported) {
instance.makeSource(windows, {
filter:".ep",
anchor:"Continuous",
connector: ["Flowchart", { stub: [40, 60], cornerRadius: 5, alwaysRespectStubs: true }],
connectorStyle:{ strokeStyle:"#5c96bc", lineWidth:4, outlineColor:"transparent", outlineWidth:4 },
maxConnections:5,
onMaxConnections:function(info, e) {
alert("Maximum connections (" + info.maxConnections + ") reached");
}
});
}
else {
var eps = jsPlumb.getSelector(".ep");
for (var i = 0; i < eps.length; i++) {
var e = eps[i], p = e.parentNode;
instance.makeSource(e, {
parent:p,
anchor:"Continuous",
connector: ["Flowchart", { stub: [40, 60], cornerRadius: 5, alwaysRespectStubs: true }],
connectorStyle:{ strokeStyle:"#5c96bc",lineWidth:4, outlineColor:"transparent", outlineWidth:4 },
maxConnections:5,
onMaxConnections:function(info, e) {
alert("Maximum connections (" + info.maxConnections + ") reached");
}
});
}
}
});
// initialise all '.w' elements as connection targets.
instance.makeTarget(windows, {
dropOptions:{ hoverClass:"dragHover" },
anchor:"Continuous",
allowLoopback:true,
anchor:"Continuous"
});
jsPlumb.fire("jsPlumbDemoLoaded", instance);
});
我正在使用jsPlumb创建一个包含两列的匹配小部件。 jsPlumb实例创建为: 我创建了源和目标,如下所示: 连接过程正常工作。但是在建立一个连接后的问题如果我删除连接,连接endpoint仍然可见。 我尝试添加配置“\u deleteondetch”,还尝试删除connectiondeach上的endpoint。在这两种情况下,endpoint都被删除,但在我尝试连接相同的元素时,它会出错。
我试图找出一种方法,如何将endpoint锚动态添加到jsPlumb容器中。 我希望源endpoint位于左侧,目标endpoint仅位于右侧。 问题是,我无法找到任何方法来做到这一点,而不是像我现在这样求助于一些黑客。 jsPlumb支持连续锚,但单个锚的位置将根据连接器之间的方向和连续锚的数量重新计算。这意味着源endpoint和目标endpoint可以共享容器的同一侧,这是我希望避免的。 这
我试图以编程方式建立一些连接。问题是,当绘制连接时,会创建新的endpoint,而现有endpoint不再可单击。我确实有拖动行为的endpoint。我无法让endpoint(由连接创建)具有与原始endpoint相同的属性。 我做了一个工作jsFiddle:http://jsfiddle.net/SCSaf/4/ 在下面的代码中,初始化容器并绘制连接 在公共变量中,我尝试将源endpoint(e
我想画一个流程图。我动态创建div,并为每个div设置了唯一的“id”属性,并使用Jsplumb连接器连接它们。 我从数据库中获取源和目标id(请注意,动态创建的div的“id”属性是其从数据库中的id),并存储在“connectors”json中。其格式如下: {[from:A,to:B],[from:A,to:C],[from:B,to:C]} jsplumb代码如下 问题: 我现在拥有的是
使用jsPlumb,我成功地进行了以下设置: 有多个节点与特殊类型流程图中的节点类似。 先举个小例子:http://fiddle.darkspot.ch/ivr/flowchart/ivrplumb.html (经过一个小时的尝试,不幸的是我没有让它在JSFIDLE上运行——所以我自己主持了它) 我想要实现的是:如果用户将新连接从一个出口拖到另一个节点,那么应该按照预期建立连接。但是应该删除此出口
我试图用jplumb库做一个流程图。我需要从一个div多个连接。Ex-Div 1应该连接到Div 2和Div 3。我希望源endpoint是相同的,即底部中心。请让我知道应该做些什么来使这项工作谢谢!