JavaScript jsPlumb connect sources and targets programmatically

I am building an UI with jsPlumb were I have multiple boxes that can be connected together. Each box has 1 target and 3 sources, made with the makeTarget and makeSource methods called upon the same box DOM element.

jsPlumb.makeTarget($('#box_id'), targetData);
jsPlumb.makeSource($('#box_id'), sourceData1);
jsPlumb.makeSource($('#box_id'), sourceData2);
jsPlumb.makeSource($('#box_id'), sourceData3);

And each of the sources is distinguished by the filter property that connects it to a different part of the box:

sourceData1.filter = '.filter_1';
sourceData2.filter = '.filter_2';
sourceData3.filter = '.filter_3';

Connections are possible to be made only between the sources of one box and the target of another box. The target anchors are Continuous.

This arrangement works perfectly for what I need as far as working with the boxes and dragging and dropping connections.

The problem arises when I want to recreate a saved UI from a JSON object. I can recreate the position of the boxes without a problem, but I cannot find a way to recreate the connections to start from the correct source of the 3 available on the box.

I tried to re-connect using the saved uuids, but it turned out the endpoints don't exist yet before the connections are created. The other method I tried is to connect just the source and target box ids:

jsPlumb.connect({ 
    source:"box_id1", 
    target:"box_id2",
});

But this never connects the correct source to the target and the connections are not exactly the same as the user made them. If a connection started from source 1, with this method it can start from source 3 for example.

Basically I am asking is it possible to programmatically connect sources and targets before the endpoints are created using the jsPlumb API?

So is it possible to recreate the connections in these circumstances or should I look for other solutions?

Thanks.

Note: You can find more info about the UI, its setting and the problem here: https://github.com/sporritt/jsPlumb/issues/77

Answer:1

I need to define different style by the value of a champ in ng-repeat, i try this : <thead> <tr><th>#</th><th>Nom</th><th>Ville</th><th style="...

I need to define different style by the value of a champ in ng-repeat, i try this : <thead> <tr><th>#</th><th>Nom</th><th>Ville</th><th style="...

  1. angularjs repeat index
  2. angularjs repeat filter
  3. angularjs repeat n times
  4. angularjs repeat orderby
  5. angularjs repeat object
  6. angularjs repeat track by
  7. angularjs repeat without element
  8. angularjs repeat limit
  9. angularjs repeat sort
  10. angularjs repeat key value
  11. angularjs repeat array
  12. angularjs repeat group by
  13. angularjs repeat filter function
  14. angularjs repeat table
  15. angularjs repeat x times
  16. angularjs repeat div
  17. angularjs repeat last
  18. angularjs repeat select option
  19. angularjs repeat element n times
  20. angularjs repeat if

I am trying to make an animation of the effect of an opening door. Is there any known algortihms for doing this? If not, I need to alter a rectangular div making the right side longer than the left ...

I am trying to make an animation of the effect of an opening door. Is there any known algortihms for doing this? If not, I need to alter a rectangular div making the right side longer than the left ...

I'm trying to debug a Firefox extension, using Firefox 28.0. I have set up the dev environment as suggested in https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment ...

I'm trying to debug a Firefox extension, using Firefox 28.0. I have set up the dev environment as suggested in https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment ...

  1. debugging firefox extension
  2. javascript debugging extension firefox
  3. firefox extension debugging not working

In Google Chrome > right click HTML page > Inspect Element > Network tab Is there a way to filter the files you see in his tab when requests are made from the browser? I sometimes get flooded with ...

In Google Chrome > right click HTML page > Inspect Element > Network tab Is there a way to filter the files you see in his tab when requests are made from the browser? I sometimes get flooded with ...