StartBootstrap / startbootstrap-sb-admin

A free, open source, Bootstrap admin theme created by Start Bootstrap
https://startbootstrap.com/template/sb-admin/
MIT License
3.23k stars 2.01k forks source link

Opening modal from link #169

Closed TechnagyDev closed 2 years ago

TechnagyDev commented 2 years ago

I am simply trying to open a modal window from a link:

<a href="#" data-bs-target="#some-modal-window" data-bs-toggle="modal">Click Me</a>

And with a simple modal pulled from the BS documentation:

<div class="modal fade" id="some-modal-window" tabindex="-1" aria-labelledby="some-modal-window-label" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

When clicking the link I get a javascript error:

Uncaught TypeError: Cannot read properties of null (reading 'hide')

Does anyone have any ideas?

I have included jQuery but have tried without this and get the same issue.

TechnagyDev commented 2 years ago

Nevermind, I had an issue because I had copied several other modals from an older Bootstrap 4 setup, which had incorrect classes, but was causing an issue. This is working just fine for me now.