我有可以拖放到绘图区域的div。可以使用鼠标从源端点拖放到目标端点来手动连接这些div。 在如此创建的连接上发生连接时,连接将被分离,但端点仍然存在,并且可以通过上述相同的手动过程重新创建已删除的连接。 现在我还将绘图以json格式的连接节点的流程图形式保存到磁盘文件中。在加载文件时,流程图将完美地显示所有连接和节点。现在我删除点击节点的连接,它可以工作。但现在我再也无法重新创建相同的连接。旧节点端点已无响应。 这是我的加载功能: -
function loadDrawing(jsPlumb,clientName,fileName){
var compositeObject = [ clientName.toString() , fileName.toString() ];
$.ajax({
type: "post",
url: contextPath+"/file/load",
beforeSend: function(xhr) {
xhr.setRequestHeader( "Content-type", "application/json" );
},
// Send client and file name to the server
data : JSON.stringify(compositeObject),
async:false,
cache: false,
contentType: false,
success: function(response){
var nodes = response.nodes;
var endpoints = response.endpoints;
var connections1 = response.connections;
$.each(nodes, function( index, elem ) {
createElement( jsPlumb, elem.cssClass , elem.blockId , elem.nodetype ,
elem.dropStatus , elem.positionX, elem.positionY , elem.html, connections1["anchors"] );
});
var connections = response.connections;
$.each(connections, function( index, elem ) {
var connection1 = jsPlumb.connect({
source: elem.pageSourceId,
target: elem.pageTargetId,
reattach: true,
anchors: elem.anchors,
endpoint:"Rectangle",
maxConnections:-1, // Unlimited Connections .
deleteEndpointsOnDetach:false,// Do not delete endpoints on connection removal.
paintStyle:{ width:10 , height:10, strokeStyle:'#666' },
isSource:true,
connector: 'Flowchart' ,
connectorStyle : { strokeStyle:"#666" },
isTarget:true
});
});
// Reset global node counters
countLLC = response.counters[0].countLLC;
countCCorp = response.counters[0].countCCorp;
countSCorp = response.counters[0].countSCorp;
countNonProfit = response.counters[0].countNonProfit;
countSeries = response.counters[0].countSeries;
countLivingTrust = response.counters[0].countLivingTrust;
countLandTrust = response.counters[0].countLandTrust;
countQRP = response.counters[0].countQRP;
countLP = response.counters[0].countLP;
wealthPlanningItemId = response.counters[0].countWPBNode;
// Display detached captions
for ( i=0 ; i<response.labelId.length ; i++) {
var detachedCaptionDiv = $('<div>').attr('id',response.labelId[i].labelId)
.html(response.labelContent[i].content);
$('#nodeCaptionContainer1').append(detachedCaptionDiv);
}
alert("Image Open Successful .");
},
error: function(){
alert("Image Open Failure");
}
});
}
// Re-create nodes
function createElement( jsPlumb , cssClass , nodeId , nodetype , dropStatus , posX, posY , content, anchor1 ) {
var recreatedNode = $('<div>').attr('id',nodeId).html( content );
recreatedNode.attr('title', nodetype );
recreatedNode.attr('dropstatus', dropStatus );
recreatedNode.attr('class', cssClass );
recreatedNode.css('position', 'absolute');
recreatedNode.css('left', posX+'px');
recreatedNode.css('top', posY+'px');
// Make nodes and their endpoints non-detachable
$(recreatedNode).removeClass("ui-draggable");
jsPlumb.draggable($(recreatedNode));
$("#content1").append(recreatedNode);
}
这是我的连接删除代码: -
jsPlumb.bind('click', function (connection, e) {
jsPlumb.detach(connection);
});
我搜索过SOF,JSplumb Google群组,JSplumb API文档,以及google抛出的大部分相关链接但找不到任何帮助。请帮忙 。
答案 0 :(得分:0)
嗨朋友们,
经过一些研究,我已经能够找出我的错误,实际上这是我不知道的事情。我试图在两个节点之间绘制连接,这些节点没有连接端点,并调用了jsPlumb.addEndpoint()。如果您不使用此功能连接端点,则无法将UUID设置为端点,因此无法从先前已连接的预先存在的端点连接这些节点。
因此,故事的寓意是您需要将端点附加到特定位置的节点,然后将UUID设置为它们,然后使用uuids连接节点,否则它不起作用。
请参阅API文档以了解有关jsPlumb.addEndpoint()和jsPlumb.connect({uuids:[ep_1.getUuid(),ep_2.getUuid()]})函数的更多信息。这些是我认为最重要的一次。
希望这能帮助所有面临同样问题的人。