Javascript also provides a nice method (.indexOf()
) for checking if an element is part of an array, so you can skip the loops altogether. Then after you've confirmed the node is part of the group, you can use the .destroy()
method to, well, destroy it.
function removesFromGroup(group, tempRect) {
if (group.getChildren().indexOf(tempRect) !== -1)
tempRect.destroy();
layer.draw();
});
return false;
}