Search code examples
javascriptangulartypescriptdraggablejsplumb

Angular 5: how to make dynamically created components draggable with jsPlumb?


I'm really struggling integrating jsPlumb into Angular. I need to make some elements draggable, and I have no problem if I create a static HTML. The problem comes when I create components dynamically, jsPlumb just seems to ignore those. I made sure to have the id properly set, but no luck. As it is a bit difficult to explain I made an example, which you can find here: example demo

Any help would be much appreciated, thanks in advance


Solution

  • I solved it calling the jsPlumb draggable() method in the ngAfterViewInit life cycle of the newly created component. I'll post the link to the demo in case someone needs it: jsPlumb demo