question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

B5 - modal not open on $('#myModal').show();

See original GitHub issue

I have been able to verify that, if there is no other problem, by calling the function $ ('# myModal').show(); it does not show the modal, and one of the things that happens is that it does not add the class “show” so it stays in opacity 0.

I could not check if something similar happens in “hide”.

Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
alecplcommented, Jun 18, 2021

Was $('#myModal').show() ever supported? As far as I know official way to open a modal was $('#myModal').modal('show'). Since Bootstrap v5 is not using jQuery you have to use .show() method of the Modal object. But I’m not an expert.

0reactions
GeoSotcommented, Jun 20, 2021

As far as I know official way to open a modal was $(‘#myModal’).modal(‘show’)

You are right on this

Bootstrap v5 is not using jQuery you have to use .show() method of the Modal object.

not using jQuery (by default), but can yet used like you proposed too 😉

In general, the Bootstrap components can be used with the following ways


// native call
arg = 'any-selector | HTMLElement object | jQuery object'
new bootstrap.Modal(arg).method()

// After 5.0.2 will be possible to use it via the static accessor too
arg = HTMLElement object
Modal.getOrCreateInstance(arg).method()

// JQuery call
arg = configuration object | method name
$('selector').modal(arg).
Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap V5 manually call a modal myModal.show() not ...
Bootstrap V5 manually call a modal myModal.show() not working (vanilla javascript) · 1. It looks like you don't have jquery - show() is...
Read more >
Modal · Bootstrap v5.0
If the height of a modal changes while it is open, you should call myModal.handleUpdate() to readjust the modal's position in case a...
Read more >
Bootstrap 5 Modal - W3Schools
The following example shows how to create a basic modal: ... class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#myModal"> Open modal </button>
Read more >
Bootstrap 5 Modal myModal.show() not working JavaScript ...
Bootstrap 5 Modal myModal. show() not working JavaScript (SOLVED) ; Professional CSS Course: https://bytegrad.com/professional-css... ;
Read more >
How to Use Bootstrap Modals Without jQuery
However, it's not too difficult to work around - in fact, it requires less ... classList.add("show") } function closeModal() { document.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found