Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing the DomNode in the dataNode #18

Open
justinqllvr opened this issue Nov 6, 2023 · 1 comment
Open

Accessing the DomNode in the dataNode #18

justinqllvr opened this issue Nov 6, 2023 · 1 comment

Comments

@justinqllvr
Copy link

Hello !
I've tested your librairy, and I'm really missing a feature to be able to do what I want with it: I'd like to have access to the DomNode in the DataNode object.

For example, when you click on a circle, I'd like to be able to add an attribute to it, so I'd need access to the tag for this circle.

I'd like to know if it's possible to add this tag to the content of the __dataNode.

If not, perhaps you already have a technique I don't know about for accessing the node?

Thanks in advance for your reply!

@vasturiano
Copy link
Owner

@justinqllvr when you click on a node, the callback returns the node object you've clicked on. Within this object, if you access node.__dataNode.id it gives you the unique id of that node.

Using this id you can find the corresponding DOM element by searching for document.getElementById(`circle-${id}`).

However, I would recommend against this approach. The internal DOM structure of this component should not be tampered with as it may have unpredictable results. Why do you need to access the DOM element? Can you perhaps achieve your intention in another way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants