Code Monkey home page Code Monkey logo

Comments (12)

mbraak avatar mbraak commented on June 11, 2024

When the tree.load_data is event is sent, the tree is not yet initialized. That is the reason that getNodeByd doesn't work.

I'll have a look if it's possible to change this.

from jqtree.

yakamuki avatar yakamuki commented on June 11, 2024

I was unable to find a way to manually open nodes after onCreateLi, where i use to customize each node. So the only way to do this was foreach node, inside onCreateLi, to add/remove css classes so to open the current node when required. But it would be great if there was an event to call after all initialization was done, including the customization of the nodes.

from jqtree.

mbraak avatar mbraak commented on June 11, 2024

I'm of thinking of adding a tree.reinit event, that is called when the whole tree is reloaded. You could then listen to the tree.init and tree.reinit events if you want to handle a tree reload.

  • tree.init: called when the tree is initialized; this event is called only once.
  • tree.reinit: called when the tree is re-initialized;

Background: I cannot call tree.init on tree reload because this breaks existing code.

It's implemented in this pr: #705. It's a work in progress, but it does work.

NB: this only works if you reload the entire tree.

Would this work for in your situation?

from jqtree.

yakamuki avatar yakamuki commented on June 11, 2024

well i'm not sure. What i actually want to achieve is that after loadDataFromUrl, i customize each node of the tree to add a custom button, using onCreateLi. After customizing all the nodes, i want to parse each node of the tree, and open some nodes i choose. My current problemt is that i cannot find an event to check wheter the onCreateLi has finished, and all nodes are visible, so to parse each node individualy.

from jqtree.

mbraak avatar mbraak commented on June 11, 2024

When you call loadDataFromUrl, are you reloading the whole tree, or only part of the tree?

Background: it's possible to load part of the tree by using the parentNode parameter. https://mbraak.github.io/jqTree/#functions-loaddatafromurl

from jqtree.

yakamuki avatar yakamuki commented on June 11, 2024

In my case i need to reload the whole tree, thats why everytime i have to customize the nodes. I think if there was an event like "onDrawFinished" which is fired after all the nodes are draw, it would be the best.

from jqtree.

mbraak avatar mbraak commented on June 11, 2024

I updated pr #705. It now triggers the tree.load_data event after the tree is (reloaded and) redrawn.

I think this should work with your original code that handles the tree.load_data event.

from jqtree.

mbraak avatar mbraak commented on June 11, 2024

@yakamuki Can I ask you to test if the #705 pull request fixes the issue? The tree.load_data event is triggered after drawing the tree, so the getNodeById call should work.

from jqtree.

yakamuki avatar yakamuki commented on June 11, 2024

@mbraak i'll give it a try now. I'm currently working on a project and installed the library via "npm"

from jqtree.

yakamuki avatar yakamuki commented on June 11, 2024

@mbraak it works great. The tree.load_data event is triggered after the whole tree is drawn, so now i can manipulate all the nodes i need. Thanks

from jqtree.

mbraak avatar mbraak commented on June 11, 2024

Thanks for testing! I'll merge the pr.

from jqtree.

mbraak avatar mbraak commented on June 11, 2024

Version 1.7.0 is just published, including this fix.

from jqtree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.