This is a follow-up to this question. (Special thanks to Cyril for the assistance!)
There is a slight complication with my issue and I require further assistance. When a user clicks on any text element of a node, I aim for the following actions to take place:
- For each ancestor of that element in the tree:
- Append "X" to the text element
- Remove the style class "class1" from the element
- Add the style class "class2" to the element
- Disable the onclick method for that element
- During this process, all other nodes should remain unaffected.
I have heeded Cyril's advice and included the parent
item in the data Object passed into collapse()
. This allows me to traverse upwards along the path to the root. However, I am facing difficulty in obtaining the d3.js element for the text as I move through this path. Once I achieve that, performing the aforementioned operations will be relatively straightforward.
Illustrated below is an example of the desired outcome. Upon clicking on Visualizations
, both viz
and flare
should transform into vizX
and flareX
respectively. Additionally, their style classes should transition from class1
to class2
. Subsequent clicks on vizX
and flareX
texts should not trigger any action. No changes should occur to any other nodes.
How can I accomplish this? I need to access the d3.js drawing elements as I navigate through the tree.