Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modal backdrop does not disappear, when modal-dialog being removed in HTML #16320

Closed
SilverFire opened this issue Apr 21, 2015 · 4 comments
Closed
Labels

Comments

@SilverFire
Copy link

Use case: I use modal for actions' confirmation.
The modal block is placed inside of a Pjax wrapper.
There OK button triggers a Pjax request, which (in case of success) replaces overall Pjax block with the new content.
When the modal block is being removed, the backdrop stays alive, because it is placed in the end of the body.

Expected behavior: the backdrop will be removed automatically, when the modal wrapper disappears.

Steps to reproduce:

  • Open Modal Live Demo, click the "Launch demo modal" button
  • Open the development console and remove corresponding modal wrapper. Just execute:
$('#myModal').remove()
  • Meditate on the stuck backdrop 😉

Guys, is it possible to fix this?

@cvrebert cvrebert added the js label Apr 21, 2015
@cvrebert
Copy link
Collaborator

X-Ref: #15632

@cvrebert
Copy link
Collaborator

I think you should be able to simply and easily address the problem yourself by using a callback on one of the events that pjax provides. Your callback would do something like $('.modal.in').modal('hide') or $('.modal-backdrop').remove()

As mentioned in the issue that I referenced, the only way to do something about this at the Bootstrap level would be to use something like Mutation Observers, but there are some concerns with that approach.

@cvrebert
Copy link
Collaborator

Punting anything involving MutationObserver to consideration for Bootstrap v4.

@mdo mdo mentioned this issue Aug 19, 2015
@remartins
Copy link

$('.modal-backdrop').remove()
$(document.body).removeClass("modal-open");

@twbs twbs locked as resolved and limited conversation to collaborators Jul 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants