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 6989087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:09:59+00:00 2026-05-27T19:09:59+00:00

On my page, i have a button, which on clicked, refreshes a jstree found

  • 0

On my page, i have a button, which on clicked, refreshes a jstree found on that page.

<input type="button" value="Test" onclick='$j("#demo2").jstree("refresh");'/>

Now, when the jstree loads, data is read from a 2D array and the node icons are changed according to the data found in that array.
I need a function which will refresh or reload the jstree and at the same time display the proper icons for the nodes based on data read from the 2D array.

If i use '$j("#demo2").jstree("refresh");', the tree is reloaded but it does not retain its previous open state.

jstree code

$j("#demo2").jstree({
          "ui" : {
            "select_limit" : -1,
            "select_multiple_modifier" : "ctrl",
            "select_range_modifier" :"shift",
          },

          "json_data" : {
            "progressive_render" : false,
            "selected_parent_open": true,
            "ajax" : {
              "url" : "/json/test1.json"
            }
          },

          "plugins" : [ "themes", "json_data", "ui", "crrm", "contextmenu" ],

          'contextmenu' : {
          'items' : customMenu
          }

      })//end of jstree function


      /***************************************************************************
      When the jstree is first loaded, loop through the data retrieved
      from the database (stored previously in a 2d array called 'status_from_db') and
      select all jstree nodes found in that array.
      ***************************************************************************/
     $j("#demo2").bind("loaded.jstree", function (e, data) {    
      var inst = data.inst;
      var i;
      for (i = 0; i < status_from_db.length; ++i) {
          var node_name = status_from_db[i][0];
          $j("#demo2").find($j("li[name='"+node_name+"']")).each(function (k, v) {
            inst.select_node(v);

      /***************************************************************************
      Based on the retrieved data, assign the correct class to the variable 
      'selected_class and then modify the class of the <li> tag of the respective 
      node.
      ***************************************************************************/
            var node_strength = status_from_db[i][1];
            var node_add_strength = status_from_db[i][2];
            var selected_class;
            if (node_strength == "present" && node_add_strength == ""){
              selected_class = "jstree-icon4";
            }
            else if (node_strength == "present" && node_add_strength == "strong")  {
              selected_class = "jstree-icon3";
            }


            $j("li[name='"+node_name+"'] > ins").attr("class",selected_class);// set class to display new icon
            $j("li[name='"+node_name+"'] > a ins").attr("class",selected_class);// set class to display new icon    
          });
      }

   });

});

Is there a way of reloading/refreshing the tree such that all code within '$j("#demo2").bind("loaded.jstree", function (e, data) {' function is re-run?

  • 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-27T19:10:00+00:00Added an answer on May 27, 2026 at 7:10 pm

    you could trigger the event yourself

    $j("#demo2").trigger("loaded.jstree");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have in my page a button which when clicked displays a div (popup
I have google analytics on my site. One page has a button which when
I have an updatepanel which after clicking one button is submitting the page. The
I have a page which has radio buttons and the selected value is taken
I have a button on my page. When clicked it triggers an ajax call
I have a button on an html page declared like so: <button type=submit name=action
I have a button on an aspx page that is supposed to send an
I have a button in my page, and onclick event, if should append to
I have a page, which on click of a button, you insert a form.
I have web form in which I have to make sure that 'SUBMIT' button

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.