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

Get parents for nodes #5

Open
vpopovic003 opened this issue Aug 7, 2022 · 1 comment
Open

Get parents for nodes #5

vpopovic003 opened this issue Aug 7, 2022 · 1 comment

Comments

@vpopovic003
Copy link

Hello there. I am using tree.js to render a tree on my page from dynamically generated JSON that I pass from Flask.
It works great.

However, I want to render a .txt file on the same page when an item in the tree is clicked.
Is there a way to get the full path of the item in your tree, will all parents?

Since I dynamically generate path for rendering .txt, I need to attach it to the base path on line 57.
If I use it as it is now on line 57, and if I file is deeper in hierarchy, I am getting no output.

Thank you!
Screenshot from 2022-08-07 10-34-36

@lunu-bounir
Copy link
Owner

Is there a way to get the full path of the item in your tree, will all parents?

Use hierarchy method.

// keep track of the original node objects
tree.on('created', (e, node) => {
  e.node = node;
});

tree.on('select', e => {
  console.log(tree.hierarchy(e).map(e => [e, e.node]));
});

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