Sequence of events on graph.on('remove', function(cell, collection, opt)

16 views
Skip to first unread message

Mat Jackson

unread,
Aug 25, 2021, 7:40:25 PM8/25/21
to JointJS
Hey everyone I am in a pickle involving the sequence of events when graph.on('remove') is called. To make this simple let's say I have three elements on a graph with two links joining them all. 
IMG_1742.jpg
When I delete element 2(container) it removes link 1 and removes the container(2), then deletes link 2 but the logic in my code when deleting link 2 requires to know the container(2) which has already been deleted. One might say "just don't delete the container on the first de link" which is a valid thought but users have the ability to just have container(2) and link 1 without having a link 2 or volume(3) so then when they delete container that object would still be in the data base and cause problems. I am wondering if there is a way to determine what order things are deleted. If the de link 2 was called, then de link 1, then delete container(2) it would be quite easy but haven't found anything in the documentation on that. Also if this doesn't make sense just let me know and I will give more information.

Thank you,
Mat 

Roman Bruckner

unread,
Aug 26, 2021, 3:29:23 AM8/26/21
to joi...@googlegroups.com
Hi Mat,

I would say find all the cells that you are about to delete first. Once you know which elements/links have to be deleted, only then you remove them from the graph.

function myDelete(el) {
  const toBeDeleted = findAllCellsToBeDeleted(el);
  toBeDeleted.forEach(cell => cell.remove());
}

Best,
Roman





--

---
You received this message because you are subscribed to the Google Groups "JointJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jointjs+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jointjs/f56690e8-e30b-4970-91c1-8e97375234e9n%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages