almende / vis

⚠️ This project is not maintained anymore! Please go to https://github.com/visjs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Calling an event as a function?

jeandav opened this issue · comments

commented

I want to create a function which will deselect the selected nodes in the network. I tried network.deselectNode();, however, I can't figure out how to trigger an event from a function.

Did you try the following approach?

  1. Call getSelectedNodes() to get an array of selected node ids in the form: [nodeId1, nodeId2, ...]
  2. Find and remove the nodeId that you want to deselect using the approach of your choice.
  3. Call unselectAll()
  4. Use setSelection() to select the object having their id in the array.

I haven't tried this myself. I just came up with it based on what I found in the documentation.

The setSelecton() accepts an option object that looking like this ...

{
  unselectAll: Boolean,
  highlightEdges: Boolean
}

Again, I haven't tested it, but if you set unselectAll to true, maybe you will not need to call the unselectAll() function at step 3.