Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6679141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:19:29+00:00 2026-05-26T04:19:29+00:00

I Have implemented JSTREE on my project everything work fine but recently I faced

  • 0

I Have implemented JSTREE on my project everything work fine but recently I faced the issue which even though I manage to fix the concept of it is still unclear to me .

Here What I meant ?

the JSTREE Code is Written in jquery document ready function
Like this

$(document).ready(function() { 
  $("#someid").jstree( { 

    "json_data" : {
      "data" : [{
        "attr" : { "id" : "root" },
        "data" : {
          "title" : "Root",
          "attr" : { "id" : "root","href" : "#" ,"class" : "jstree-clicked" }
        },
        "children" : [
              {
              "attr" : {"id" : "node-1"},
              "data" : {
                "title" : "Node-1",
                "attr" : {"id" : "node-1" ,"href": "#" }
              },
              "children": [

              ],
              "state" : "closed"
            },

              {
              "attr" : {"id" : "node-2"},
              "data" : {
                "title" : "Node-2",
                "attr" : {"id" : "node-2" ,"href": "#" }
              },
              "children": [

              ],
              "state" : "closed"
            },

              {
              "attr" : {"id" : "node-3"},
              "data" : {
                "title" : "Node-3",
                "attr" : {"id" : "node-3" ,"href": "#" }
              },
              "children": [

              ],
              "state" : "closed"
            },

              {
              "attr" : {"id" : "node-4"},
              "data" : {
                "title" : "Node-4",
                "attr" : {"id" : "node-4" ,"href": "#" }
              },
              "children": [

              ],
              "state" : "closed"
            },

              {
              "attr" : {"id" : "node-5"},
              "data" : {
                "title" : "Node-5",
                "attr" : {"id" : "node-5" ,"href": "#" }
              },
              "children": [

              ],
              "state" : "closed"
            }
     ],
     // the method where the ajax request will be sent to get thejson data to build the tree
    "ajax" : {
      "url" : "/my_url/tree",
      "data" : function (focus_element) {
        return { node : focus_element.attr ? focus_element.attr("id") : 0 };
      }
    }
  },

  "themes" : {
    "theme" : "classic",
    "dots" : true,
    "icons" : true
  },
  "plugins" : ["themes",  "json_data" ,"ui"]

})

There is a another jquery document ready function on the page which will click the anchor node created but the above jstree .

$(document).ready(function() {

 $("a#node-1").click()     

})

Now The problem come when the page is load the tree is constructed all
the tree is constructed but the node-1 anchor link is not getting clicked .

Debugging it I found That the console.log always present me and empty array for a#node-1 which is very weird.

I put alert box in second document.ready function to see whether the tree is constructed when I’m requesting for the node. like this

$(document).ready(function() {

alert("JSTREE SHOULD BE CREATED BY NOW");

$("a#node-1").click()  

})

But to my astonishment the when the alert popped up JSTREE was still build the tree .

With some decent understanding of javascript I know that script tag on the page are synchronous in nature i.e the second script on the page execute only when the first execute

This make me believe is JSTREE running asynchronously .If yes Can please any one share some light on it .

By the Way I manage to achieve the same using jstree load handler

$(“#someid”).bind(“loaded.jstree”,

   function() {   
       $("a#node-1").click();   
       })
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:19:30+00:00Added an answer on May 26, 2026 at 4:19 am

    Your question has an interesting answer: I just found out that the code in jquery.jstree.js (jsTree 1.0-rc3), uses setTimer(…) to call .init() on the nodes, i.e. is asynchronous. I also used jsTree 1.0-rc1 in other project and it is synchronous.

    I am afraid you won’t find this documented as it is an implementation detail: it depends on the version you use.

    As suggested by others, use the event mechanism in jstree to achieve what you want.
    On the other hand, Jurgen was right about the structure of the DOM.

    (*) I browsed thru Github to see the original code, it seems the change happened in 2011. Before that you had:

    jsTree 1.0-rc1
    https://github.com/vakata/jstree/blob/0b8ebb2ba468b4c81e3c7645a9335584ddab41f5/jquery.jstree.js

    line 59: instances[instance_id]._init();
    

    whereas now,

    jStree 1.0-rc3
    https://github.com/vakata/jstree/blob/v.pre1.0/jquery.jstree.js

    line 162: setTimeout(function() { instances[instance_id].init(); }, 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented Solr search in one of my .net application. Everything working fine
i have implemented galleryview in one screen named display_image.xml in which i have shown
I have implemented multiple-stroke gestures in my app, but if the pause between strokes
I have implemented a REST Webservice which returns (after an authentication via RFC 2617
I have implemented button which clicks and opens dialog with spinner inside as described
I have a external draggable object (draggable implemented through jstee's dnd) on which I
I have implemented SSO authentication using the sourceforge spnego project . This is my
I have implemented one application in android which uses epublib to view .epub files.
I have implemented a function to validate .edu domains. This is how I am
I have implemented basic syntax highlighting by properly setting the NSTextStorage delegate of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.