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

  • SEARCH
  • Home
  • 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 8877655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:31:03+00:00 2026-06-14T19:31:03+00:00

I have a jstree tree that all the tree items are loaded using ajax

  • 0

I have a jstree tree that all the tree items are loaded using ajax calls to my server to populate the children of each folder. I am trying to build a function that will drill down through the tree and select a child depending on what I pass into the function. I am currently using the following function to do this, but my $.when(…).done(…) function is not waiting for the open to occur and then can’t load any children below it.

function openNodes(tree, nodesToOpenRaw, selectedNode) {
    var treeObj = $(tree);
    treeObj.one('loaded.jstree', function() {
        openNodesRaw(treeObj, nodesToOpenRaw, selectedNode);
    });
}

function openNodesRaw(tree, nodesToOpen, selectedNode) {
    if (tree.jstree('is_open', nodesToOpen[0])) {
        goToNextNode(tree, nodesToOpen, selectedNode);
    } else {
        $.when(tree.jstree("open_node", nodesToOpen[0])).done(function () {
            if (nodesToOpen[0] == null) {
                goToNextNode(tree, nodesToOpen, selectedNode);
                return;
            }
            goToNextNode(tree, nodesToOpen, selectedNode);
        });
    }
}

function goToNextNode(tree, nodesToOpen, selectedNode) {
    if (nodesToOpen.length > 0 && Object.prototype.toString.call(nodesToOpen) === '[object Array]') {
        var newNodesToOpen = nodesToOpen.slice(0);
        newNodesToOpen.shift();
        openNodesRaw(tree, newNodesToOpen, selectedNode);
    } else {
        tree.jstree("select_node", selectedNode, true);
        tree.unbind('ajaxSuccess');
    }
}

Why is the $.when function waiting for the ajax call of tree.jstree(“open_node”,….) to finish before continuing on with the next function?

  • 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-06-14T19:31:04+00:00Added an answer on June 14, 2026 at 7:31 pm

    The $.when() expects its arguments to be jQuery $.Deferred.

    Presumably tree.jstree() returns something else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange problem with JSTree and Ajax. I generate my tree via
Currently, I have two Stored Procedures in SQL Server that handle retrieving a tree
I have a tree(jstree) inside a div, so when a node gets expanded the
I have 2 classes. ErdosStruct contains all the data that needs to go into
I have a ASP.NET MVC 4.0 project using JsTree. The JsTree is being populated
I'm using jsTree and I have 2 textboxes: <input type=text id=previous_tree_id value= /><hr />
I have a JsTree that gets populated based on the JSON Data that I
I have two questions regarding jsTree: I am generating a jsTree using JSON with
I have some custom JTree. That tree has nodes with custom icons. I also
I have a application which uses a JTree. For each node in the tree,

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.