title: In jsTree, how can we have nodes initially selected after replacing tree?
body: <p>In jsTree, I want to draw a new tree replacing the previous one and have nodes initially selected in the new tree.</p>
  
  <p>In the code below, I confirmed that <code>state : {opened : true}</code> made the node initially opened and <code>state : {disabled : true}</code> made the node initially disabled, so I thought <code>state : {selected : true}</code> works too, but actually it is not.</p>
  
  <p>Please note that specifying <code>state : {selected : true}</code> when calling <code>$('#using_json').jstree({...});</code> does result in the node selected as described in <a href="https://www.jstree.com/docs/json/" rel="nofollow noreferrer">https://www.jstree.com/docs/json/</a>. Then, I wonder why <code>state : {selected : true}</code> does not work when I replace a existing tree with a new tree (while <code>state : {opened : true}</code> and <code>state : {disabled : true}</code> are working).</p>
  
  <p>How can we achieve nodes to be initially selected after replacing tree?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$('#using_json').jstree({ 'core' : {
      data : [
        {
           text : 'Previous root node',
        }
      ]
  } });
  
  const newData = [
         {
           text : 'New root node (Initially opened)',
           state : {
             opened : true,       //'opened' takes effect after refresh
           },
           children : [
             { text : 'Child 1 (Initially disabled)',
               state : {
                 disabled : true, //'disabled' takes effect after refresh
               }
             },
             { text : 'Child 2 (Intended to be selected initially but failing)',
               state : {
                 selected : true  //'selected' does NOT take effect after refresh
               }
             }
           ]
        }
      ]
  
  $('#using_json').jstree(true).settings.core.data = newData;
  $('#using_json').jstree(true).refresh(true);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.4/themes/default/style.min.css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;script src="https://code.jquery.com/jquery-3.1.0.js"&gt;&lt;/script&gt;
    &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.4/jstree.min.js"&gt;&lt;/script&gt;
    &lt;div id="using_json"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>