Search code examples
jquerynullsavejsplumbconnection

jsPlumb getConnections return null


After a review here, I found the code where one can find all connectors. I copied the code but without success to return the connections.

Explaining what my code does: I have an empty workflow and the manager will click to add an element and make the connections as needed.

This is dynamic and who creates is the "_addEndpoints".

Who is running the save is the ID (#salvar) which added 2 each.

1) The first is the ID and stores the top and left information.

2) The second was to store the connections.

Now I ask, what did I do wrong? The process of creating the elements is wrong?

var connections = [];
$.each(jsPlumb.getConnections(), function (idx, connection) {
connections.push({
    connectionId: connection.id,
    pageSourceId: connection.sourceId,
    pageTargetId: connection.targetId
});
});
console.log(connections);

On the console of my jsfiddle you may notice that returns nothing connections.

https://jsfiddle.net/braziel/Lnbkyr0e/


Solution

  • Just replace $.each(jsPlumb.getConnections(), function (idx, connection)... with $.each(instancia.getConnections(), function (idx, connection)....

    jsPlumb and instancia are the different instances in your source code.