I been having this problem since last night, I want to delete some links from the diaram programmtically. Here’s the code.
let linksToRemove = [];
node.findLinksInto().each(function(link) {
linksToRemove.push(link);
});
node.findLinksOutOf().each(function(link) {
linksToRemove.push(link);
});
linksToRemove.forEach(function(link){
console.log(diagram.model.containsLinkData(link.data)); // return false !!!! This should be true. some times return true though
diagram.model.removeLinkData(link);
console.log(diagram.model.containsLinkData(link.data)); // return false
});
This result in sometime the links are deleted while sometime is not. I dont know what could be the issue?
The problem with your original code, @Kakit, is that you were calling GraphLinksModel.removeLinkData on the Link instead of on the Link.data. Only the data is in the model, not the Link (or Node) object.
In addition, Simon has improved the code to be clearer and simpler.