I am using the D3 library to move an element in a Venn diagram. When I stop dragging, I want to determine the position of an element in the diagram.
item.call(d3.drag()
.on("start", this.dragstarted)
.on("drag", this.dragged)
.on("end", this.dragended)
);
These are the functions that I call when the drag and drop starts, happens and ends.
dragended(d: TCMemberScenario, i: number) {
d3.select(this).classed("active", false);
d.calculateRoles();
this.save();
}
This is the function that is called when the drag is completed. I update some things in the diagram, and then I want to call the save method. This is another method in the class. However, this variable refers to a D3 object, not an instance of a class. This way I get "Uncaught TypeError: cannot read property" save "undefined"
How can I call another method of my class from a drag method?