title: How to fire a select node event of a jsTree after re-populting it
body: <p>I have a requirement of populating my jsTree and firing few ajax calls on selection of any node of jsTree which I am able to it. But the problem is I have to re-populate the same tree and firing that ajax call again. After re-populating, I am not able to firing that SELECT or CLICK NODE event on selection of any tree node. Below is the code.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"
      src="//static.jstree.com/3.2.1/assets/dist/jstree.min.js"&gt;&lt;/script&gt;
  &lt;link rel="stylesheet"
      href="//static.jstree.com/3.2.1/assets/dist/themes/default/style.min.css" /&gt;
  &lt;script&gt;
  
  $(document).ready(function(){
  
  $("#tree").on("select_node.jstree", function(event, node) {
      $("#para").text("");
      var selected = node.instance.get_selected();
      if(selected.length === 1) {
        $("#para").text(selected[0]); // Here goes my ajax call.
      } else if(selected.length &gt; 1) {
        alert("hi");
      }
    });
  
  });
  
  function getData(){
      $('#tree').jstree("destroy").empty();
  
  
      $('#tree').jstree({
         'core' : {
           'data' : [
             { "id" : "ajson1", "parent" : "#", "text" : "Root node1" },
             { "id" : "ajson2", "parent" : "#", "text" : "Root node 2" },
             { "id" : "ajson3", "parent" : "ajson2", "text" : "Child 1" },
             { "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2" },
           ]
         }
       });
    }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;a id="go" href="#" onclick="getData()"&gt;Get Tree&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
  
  
  &lt;div id="tree"&gt;&lt;/div&gt;
  
  &lt;p id="para"&gt;&lt;/p&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>You can paste this code directly in w3school site and test. Not able make a jsFiddle of it.</p>