title: Cannot get Modal in Bootstrap 5 to open up using JavaScript
body: <p>I'm currently trying to create a loading dialog with bootstrap 5.</p>
  <p>So the first thing I did is copied to the dialog from the documentation into my test html:</p>
  <pre><code>        &lt;div class=&quot;modal fade&quot; id=&quot;staticBackdrop&quot; data-bs-backdrop=&quot;static&quot; data-bs-keyboard=&quot;false&quot; tabindex=&quot;-1&quot; aria-labelledby=&quot;staticBackdropLabel&quot; aria-hidden=&quot;true&quot;&gt;
              &lt;div class=&quot;modal-dialog&quot; id = &quot;waitDialog&quot;&gt;
              &lt;div class=&quot;modal-content&quot;&gt;
                  &lt;div class=&quot;modal-header&quot;&gt;
                  &lt;h5 class=&quot;modal-title&quot; id=&quot;staticBackdropLabel&quot;&gt;Modal title&lt;/h5&gt;
                  &lt;button type=&quot;button&quot; class=&quot;btn-close&quot; data-bs-dismiss=&quot;modal&quot; aria-label=&quot;Close&quot;&gt;&lt;/button&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;modal-body&quot;&gt;
                     Some Stuff. 
                  &lt;/div&gt;
                  &lt;div class=&quot;modal-footer&quot;&gt;
                  &lt;button type=&quot;button&quot; class=&quot;btn btn-secondary&quot; data-bs-dismiss=&quot;modal&quot;&gt;Close&lt;/button&gt;
                  &lt;button type=&quot;button&quot; class=&quot;btn btn-primary&quot;&gt;Understood&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;  
  </code></pre>
  <p>Then I wrote a bit of JS to try to open it up following the instructions in the documentation</p>
  <pre><code>  var myModal = document.getElementById('waitDialog');
    var modal = bootstrap.Modal.getInstance(myModal)
    modal.show();
  </code></pre>
  <p>This is comming straight from the documetation at <a href="https://getbootstrap.com/docs/5.0/components/modal/#via-javascript" rel="nofollow noreferrer">https://getbootstrap.com/docs/5.0/components/modal/#via-javascript</a></p>
  <p>I doesn't work because modal is null. What am I doing wrong?</p>