title: Uncaught TypeError: $(...).jstree is not a function
body: <p>I'm trying to create jstree but I want it to load after a few seconds,
  I have a code that works but if I put it in another function for example setTimeOut I get an error Uncaught TypeError: $ (...). Jstree is not a function</p>
  <p>This is my scripts:</p>
  <pre><code>  &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js&quot;&gt;&lt;/script&gt;
    &lt;link rel=&quot;stylesheet&quot; 
    href=&quot;https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css&quot; /&gt;
  </code></pre>
  <p>And if I put this code then everything is fine:</p>
  <pre><code>       &lt;script&gt;
          let cld;
          let rr = [{ text: &quot;1001&quot;, id: &quot;190&quot;, type: &quot;1&quot;, children: true }
              , { text: &quot;1002&quot;, id: &quot;192&quot;, type: &quot;1&quot;, children: true }
              , { text: &quot;1004&quot;, id: &quot;203&quot;, type: &quot;3&quot;, children: true }
              , { text: &quot;8002&quot;, id: &quot;308&quot;, type: &quot;1&quot;, children: true }
              , { text: &quot;1007&quot;, id: &quot;314&quot;, type: &quot;1&quot;, children: true }
              , { text: &quot;9001&quot;, id: &quot;316&quot;, type: &quot;3&quot;, children: true }
              , { text: &quot;6513&quot;, id: &quot;331&quot;, type: &quot;3&quot;, children: true }];
  
          $('#tree').jstree({
                    'core': {
                        'data': function (node, cb) {
                               if (node.id === &quot;#&quot;) {
                                    cb(rr);
                               }
                               else {
                                    cld = [{ text: &quot;9001&quot;, id: &quot;316&quot;, type: &quot;3&quot;, children: true }
                                           , { text: &quot;6513&quot;, id: &quot;331&quot;, type: &quot;3&quot;, children: true }];
                                     cb(cld);
                                  }
                              }
                          }
                      });
  &lt;/script&gt;
  </code></pre>
  <p>But if I put this code into a function setTimeOut for example:</p>
  <pre><code> &lt;script&gt;
          let rr = [{ text: &quot;1001&quot;, id: &quot;190&quot;, type: &quot;1&quot;, children: true }
              , { text: &quot;1002&quot;, id: &quot;192&quot;, type: &quot;1&quot;, children: true }
              , { text: &quot;1004&quot;, id: &quot;203&quot;, type: &quot;3&quot;, children: true }
              , { text: &quot;8002&quot;, id: &quot;308&quot;, type: &quot;1&quot;, children: true }
              , { text: &quot;1007&quot;, id: &quot;314&quot;, type: &quot;1&quot;, children: true }
              , { text: &quot;9001&quot;, id: &quot;316&quot;, type: &quot;3&quot;, children: true }
              , { text: &quot;6513&quot;, id: &quot;331&quot;, type: &quot;3&quot;, children: true }];
  
      setTimeout(function () {
  
          $('#tree').jstree({
                    'core': {
                        'data': function (node, cb) {
                               if (node.id === &quot;#&quot;) {
                                    cb(rr);
                               }
                               else {
                                    cld = [{ text: &quot;9001&quot;, id: &quot;316&quot;, type: &quot;3&quot;, children: true }
                                           , { text: &quot;6513&quot;, id: &quot;331&quot;, type: &quot;3&quot;, children: true }];
                                     cb(cld);
                                  }
                              }
                          }
                      });
      }, 1000);
  
  &lt;/script&gt;
  </code></pre>
  <p>I get the error:</p>
  <pre><code> Uncaught TypeError: $(...).jstree is not a function
  </code></pre>
  <p>What's the problem with my code?</p>
  <p>Thanks</p>