I'd like to use vis.js for displaying and editing a graph (hence storing its nodes, edges and options). To implement this, I need to save changes of the network (=graph) on various events. On of them is rearranging via drag and drop.
Now, there's an on method which supports the dragEnd event meaning I can do stuff like
network.on("dragEnd",saveToTiddlerAfterDragging);
However what's passed to the handler is this object:
{
nodes: [Array of selected nodeIds],
edges: [Array of selected edgeIds],
event: [Object] original _ event,
pointer: {
DOM: {x:pointer_x, y:pointer_y},
canvas: {x:canvas_x, y:canvas_y}
}
}
Seems like there's no reference of the network itself. So how to access it? I'd like to define saveToTiddlerAfterDragging in another scope than network itself.
Ok, while reading docs and writing the question, I wild-guessed that the
networkis actuallythisin the event handler context. Not sure if it's true for all the event handlers but works with thedragEndone.