This happened to me when I used the wrong method to open the modal. I had

$('#myModal').show()

when of course it should be

$('#myModal').modal('show')

Another symptom of using the wrong method, in addition to the semi-opaque backdrop not showing, was the close button in the modal also did not work.

Answer from Michael Hinds on Stack Overflow
🌐
Bootstrap
getbootstrap.com › docs › 4.4 › components › modal
Modal · Bootstrap
When backdrop is set to static, the modal will not close when clicking outside it.
🌐
Bootstrap
getbootstrap.com › docs › 5.0 › components › modal
Modal · Bootstrap v5.0
When backdrop is set to static, the modal will not close when clicking outside it.
🌐
MDBootstrap
mdbootstrap.com › standard › material design for bootstrap 5 & vanilla javascript
Modal backdrop is not working - Material Design for Bootstrap
Not able to click on the body of the component except on the modal. For example user clicked on the Recommended Questions button and opened a modal with backdrop=false, but when try to click on the button again it's not allowing to click on that button.
🌐
Drupal
drupal.org › project › bootstrap › issues › 3018531
Modal-backdrop doesn't disappear [#3018531] | Drupal.org
September 13, 2024 - We are experiencing this issue, and I do think it is an issue with the Bootstrap theme. Feel free to close the issue again if you feel this isn't related. In our case we are having issues with a modal generated by the autologout module. When the modal is closed autologout.js calls jquery modal's destroy function $(this).dialog("destroy") (Dialog destroy documentation) This closes the modal, but leaves the backdrop visible.
🌐
GitHub
github.com › twbs › bootstrap › issues › 15136
Modal Backdrop (nearly) never fits · Issue #15136 · twbs/bootstrap
September 12, 2014 - Even bootstraps own functions don't use the modal handling. So with every collapsable panel inside a modal I will have problems with the backdrop. Why the hell was this changed in 3.3.0? From my point of view the modals worked perfectly before 3.3.0!
Author   DaSchTour
🌐
Rick Strahl's Web Log
weblog.west-wind.com › posts › 2016 › sep › 14 › bootstrap-modal-dialog-showing-under-modal-background
Bootstrap Modal Dialog showing under Modal Background - Rick Strahl's Web Log
September 14, 2016 - I've experimented with a lot of different things and the only things that work reliably are not using a background and delay updating the z-order (out of band). ... I ran into the same problem using bootstrp-dialog and this worked for me. Has the added bonus that the dialog doesn't close if you accidently click on the background. ... I solved it like you said and to simulate that backdrop I simply add background to modal in rgba format
Find elsewhere
Top answer
1 of 16
596

Make sure you're not replacing the container containing the actual modal window when you're doing the AJAX request, because Bootstrap will not be able to find a reference to it when you try to close it. In your Ajax complete handler remove the modal and then replace the data.

If that doesn't work you can always force it to go away by doing the following:

$('#your-modal-id').modal('hide');
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
2 of 16
67

Make sure that your initial call to $.modal() to apply the modal behavior is not passing in more elements than you intended. If this happens, it will end up creating a modal instance, complete with backdrop element, for EACH element in the collection. Consequently, it might look like the backdrop has been left behind, when actually you're looking at one of the duplicates.

In my case, I was attempting to create the modal content on-the-fly with some code like this:

myModal = $('<div class="modal">...lots of HTML content here...</div><!-- end modal -->');
$('body').append(myModal);
myModal.modal();

Here, the HTML comment after the closing </div> tag meant that myModal was actually a jQuery collection of two elements - the div, and the comment. Both of them were dutifully turned into modals, each with its own backdrop element. Of course, the modal made out of the comment was invisible apart from the backdrop, so when I closed the real modal (the div) it looked like the background was left behind.

🌐
W3Schools
w3schools.com › bootstrap › tryit.asp
Modal Options
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
GitHub
github.com › cypress-io › cypress › issues › 25202
Bootstrap modal and backdrop issue · Issue #25202 · cypress-io/cypress
December 17, 2022 - Current behavior Having this bootstrap modal displayed, when clicking "Close", modal is hidden, but backdrop is always here (Working on Chrome or Safari). Currently I do this to avoid the issue: cy.get('.modal-backdrop.fade.show').then((...
Author   lugosium
🌐
GitHub
github.com › bootstrap-vue › bootstrap-vue › issues › 3438
Modal backdrop is not getting the .show and .fade classes applied · Issue #3438 · bootstrap-vue/bootstrap-vue
June 4, 2019 - Describe the bug Modal backdrop is opaque because it is not getting the .show and .fade classed applied Steps to reproduce the bug Create a modal assigned to a button using its id Click on the butt...
Author   garhbod
🌐
ASPSnippets
aspsnippets.com › questions › 131531 › Solved-Bootstrap-Modal-backdrop-does-not-disappear-after-modal-close-in-ASPNet-MVC
Solved Bootstrap Modal backdrop does not disappear after modal close in ASPNet MVC
October 19, 2020 - Hi I want to display modal popup in the system When i tried the modal in jsfiddle it worked but when in my system the modal become invisible but when i check inspect element the modal is exist The class of modal that i use is modal fade but when i change to modal it work just the background ...
🌐
GitHub
github.com › valor-software › ngx-bootstrap › issues › 853
Backdrop not being removed after hiding Modal · Issue #853 · valor-software/ngx-bootstrap
August 17, 2016 - I have a custom component that shows a Modal after clicking a button. Within the Modal body, the user user is presented a anchor link that routes the user away from the current view. When the user does so, the Modal is hidden/destroyed but the Backdrop is not.
Author   JayCallas
🌐
nopCommerce
nopcommerce.com › en › boards › topic › 40488 › bootstrap-modal-behind-backdrop-please-help-cant-get-it-working
BootStrap modal behind backdrop, please help :( cant get it working.... - nopCommerce
February 11, 2016 - ... Same problem here. solution above makes sense because according to this http://stackoverflow.com/questions/10636667/bootstrap-modal-appearing-under-background, placing the modal just before the closing </body> tag should solve this problem..