Calling an event as a function?
jeandav opened this issue · comments
jean 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.
Abdoulaye Siby commented
Did you try the following approach?
- Call
getSelectedNodes()
to get an array of selected node ids in the form:[nodeId1, nodeId2, ...]
- Find and remove the
nodeId
that you want to deselect using the approach of your choice. - Call
unselectAll()
- 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.