我已经坚持了几天,希望你的帮助知道如何解决这个问题。 我创建了这个应用程序,就像一个流程图,用于绘制不同类型的铅垂项目,并附加不同的端点。在将其创建为元素之后,根据铅项的类型动态添加端点。是这样的。
这是我创建铅锤物品的方式。
var element = document.createElement("div");
element.setAttribute("id",schema_id);
element.setAttribute("class","item " +control.Type);
element.setAttribute("style","left:" +posX + "px ; top: "+posY+"px");
var output = document.getElementById('container');
output.appendChild(element);
然后我根据其类型添加端点。
jsPlumb.addEndpoint(element,<the style goes here>,{ anchor:<the location of the endpoint goes here>, uuid: <a new ID is created for this>});
这就是它的样子
我设法抓住方法中的数据&#34; GetConnections&#34;并将其作为JSON保存在数据库中。此JSON包含用于plumb项和所有端点的所有ID。
但是当我尝试将其再次检索回UI时,它看起来像这样。除了端点之外,一切看起来都很棒。
在重绘时,端点的创建方式与上面提到的相同。要重新连接端点,我正在使用此代码。
jsPlumb.connect({ source:<source id>, target:<target id>,anchors:<location of the endpoint>,<style>);
问题:
对于上面的代码,虽然我将端点的UUID赋予源和目标,但它并不将其识别为要连接的端点。
有没有办法找到ID并让它们连接?我发现只有plumb项目可以用&#34; getElementById&#34;使用UUID而不是端点。
问题是如何使这些端点按原始绘制方式连接。如何再次连接每个端点?我有所有的ID,当它们被重新绘制时,它们具有与保存时相同的ID。但我无法找到一种方法再次将端点连接回来,因为它具有特定于每个铅锤项目的不同类型的端点。
有什么建议吗?
对不起,很长的帖子 提前谢谢!!
答案 0 :(得分:1)
如果您连接ids,元素或端点,请使用
jsPlumb.connect({source:<source id>, target:<target id>});
但如果连接两个端点的UUID数组,请使用
jsPlumb.connect({uuids:<array of uuids>});