org-chart
org-chart copied to clipboard
Getting id of active node
Hi, in the full futuristic example found here, the onclick events for the buttoms have the node id hard coded:
<button onclick='chart.setHighlighted("O-6162").render()' class="btn btn-action-button waves-effect waves-light">
<i class="fas fa-highlighter"></i> mark</button
Is there are way so that the last known active id, eg a node that has just been expanded, can be referenced in an onclick event? I might be missing something simple here, but any help would be appreciated.
I don't think that there is a straightforward way to do it.
Workaround: in the node update function add an additional custom event listener for the button content and save activeNode reference in the external variable
let activeNode;
chart.nodeUpdate(function(){
d3.select(this).select('.node-button-g').on('click.active-node',d=>{
activeNode = d;
})
})