Forked from thedamon/backbutton close bootstrap modal
Last active
June 1, 2021 08:13
-
-
Save tdsymonds/23917215f591a9e1442a38783c77f0f0 to your computer and use it in GitHub Desktop.
Cause back button to close Bootstrap modal windows
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works great, thanks!
My only problem was that clicks next to the modal closed it, but did not clear the history entry, so I had to click through several empty history entries.
My solution was to listen to the
hide.bs.modal
-event (instead of the different close-triggers individually) and using history.back() if the hash-fragment is still there (user did not use back button, but close icon, overlay, etc).Might be helpful to someone else:
edit: Added a referrer-check