Modal doesn't hide when shortly a show
See original GitHub issueWhen hiding a modal too soon after showing, it won’t hide.
Reproducable: $("#some-modal").modal('show'); $("#some-modal").modal('hide')
The modal is still shown afterwards. This code seems useless, but in general I use modals for loading pop-ups, to indicate that the user has to wait. Sometimes the loading goes fast causing the hide
to be called too shortly after the show
in order for the hiding to work.
I fixed it in an ugly way doing:
var int = setInterval(function() {
if ($("#some-modal").is(":visible"))
$("#some-modal").modal('hide');
else
clearInterval(int);
}.bind(this), 100);
Maybe there is a fix in the bootstrap code possible? Thanks in advance!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:15 (6 by maintainers)
Top Results From Across the Web
Bootstrap modal hide is not working - Stack Overflow
You are using both modal toggling methods: via Javascript and via data attributes. So your click is firing the modal show as your...
Read more >Modal - Bootstrap
The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also adds .modal-open to the <body> to override...
Read more >How to hide Bootstrap modal with JavaScript? - GeeksforGeeks
This article will tell us how the bootstrap executes when the .modal (modal window) gets closed. At some point of time, the modal...
Read more >Bootstrap 5 Modal Show, Close, Hide & Toggle - free examples
Modal Backdrop ; hide, Manually hides a modal. Returns to the caller before the modal has actually been hidden (i.e. before the hidden.mdb.modal...
Read more >Tailwind CSS Modal / Dialog - Free Examples & Tutorial
Set backdrop to static so the modal doesn't close when you click outside of it. Launch static backdrop modal ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
My answer to issue was to replace the modal with simple in-line spinner, I think it is less invading.
You can simply listen to
hide.bs.modal
andhidden.bs.modal
and you’ll be sure your modal is hidden. If you prevent theshow.bs.modal
event your modal won’t be visible.