How to retrieve deleted node data

Hey there, I have a question about Diagram Events.

When I double click in the background to create a new node, the PartCreated event is fired with the e.subject.part.data . containing the data I have linked to that node. When I select the node, and delete it, the SelectionDeleting and SelectionDeleted events are fired. How do I get out that same data found in e.subject.part.data with the delete events? Thanks!

Almost exactly the same way, except that you have to realize that there might be more than one Part being deleted, so e.subject will be a collection. Try these listeners:

"SelectionDeleting": function(e) { e.subject.each(function(p) { console.log(p.part.data); }) },
"SelectionDeleted": function(e) { e.subject.each(function(p) { console.log(p.part.data); }) }

And notice the difference when deleting a node that has links connected with it.

1 Like

Perfect, thank you so much @walter!