SpoonMeiser
SpoonMeiser

Reputation: 20417

Is there a safe way to delete a JointJS paper/graph

I'm writing an app that makes use of JointJS to display diagrams.

However, I want to be able to dynamically add and remove diagrams from a page. Adding new diagrams is fairly trivial, but when I remove diagrams, is it safe to remove the DOM elements and let the graph and paper objects get garbage collected?

Upvotes: 4

Views: 3207

Answers (1)

dave
dave

Reputation: 4403

Yes, that's almost it. Better yet is to call graph.clear() (to remove all the cells from the graph and their associated views from the paper) and then paper.remove() (to cleanup the paper from the DOM, including its event handlers).

Upvotes: 6

Related Questions