-5

I started with the JavaScript library Joint js, I want to dynamically create a link between two node already created by selecting the source node but without using the ports is that it is possible, thanks for your help

Sincerely yours

br.ala
  • 1
  • 2

2 Answers2

1

By dynamically, do you mean in Javascript?

If so, then you just need to use the link constructor, specifiying the source element (where the link starts from) and the target element (where it ends):

//say you have already got the source and target elements sourceEl and targetEl

var link = new joint.dia.Link({
   source: sourceEl,
   target: targetEl
});

graph.addCell(link); 

Here is a working JSFiddle.

There is documentation for this on the JointJS website - for example, the hello world sample at http://www.jointjs.com/tutorial

Mike Goodwin
  • 8,810
  • 2
  • 35
  • 50
1
var link = new joint.dia.Link({
            source: { id: source.id },
            target: { id: target.id },
            vertices: [{ x: 400, y: 250 }],           
        }),  
Nonay Goy
  • 31
  • 5