Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSPlumb - setting connection ID

Tags:

jsplumb

We're working on a project that uses JSPlumb for workflow rendering and maintaining a separate data model that includes nodes (id, position, text etc.) and connections, keeping this in sync with events using jsPlumb.bind

When I come to recreate my connections I'm calling jsPlumb.connect with source and destination parameters but it seems that the ID is created behind the scenes and therefore doesn't match what was loaded from the data model. This would be fine except on detatching I wan't to remove that connection by ID from the model...

Is there any way to set the ID of a connector manually?

Thanks

like image 816
managedheap84 Avatar asked Sep 12 '13 15:09

managedheap84


2 Answers

You can set the id directly from the connection:

var conn=jsPlumb.getConnections({
  scope:'myScope", 
  source:"mySourceElement", 
  target:"myTargetElement"
});

conn.id=elem.connectionId;
like image 167
Santhosh Avatar answered Dec 31 '22 19:12

Santhosh


From the API Documents I couldn't find function for getting Connections with attribute ID, even though you can set ID to connection using setParameter(API DOC). Instead you can remove the connection with sourceId and targetId rather than by connection ID.

var conn=jsPlumb.getConnections({
  scope:'myScope", 
  source:"mySourceElement", 
  target:"myTargetElement"
});
jsPlumb.detach(conn,param)  //by default param is false which defines whether to fire event on connection detach
like image 34
MrNobody007 Avatar answered Dec 31 '22 20:12

MrNobody007