2

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.

4

1 回答 1

2

好的,在阅读文档和编写问题时,我猜测它network实际上是this在事件处理程序上下文中。不确定这是否适用于所有事件处理程序,但适用于dragEnd一个。

于 2017-09-07T17:15:23.440 回答