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 fires multiple hide events when closed multiple times via clicking backdrop. #9111

Closed
RGBboy opened this issue Aug 5, 2013 · 2 comments
Labels

Comments

@RGBboy
Copy link

RGBboy commented Aug 5, 2013

When a user opens a modal and closes it by clicking the backdrop multiple times, the 'hide.bs.modal' event will fire an increasing number of time.

This is caused by the Modal.backdrop function attaching a click event listener every time the modal is shown.

RGBboy pushed a commit to RGBboy/bootstrap that referenced this issue Aug 5, 2013
@RGBboy RGBboy mentioned this issue Aug 5, 2013
@fat fat closed this as completed in a4f0e8d Aug 10, 2013
@KoderES
Copy link

KoderES commented Nov 26, 2013

There's a way for not touch the core, but i don't know if it's cleaner or dirtier.

$('#MyModal').on('hide.bs.modal', function () {
$(this).off('hide.bs.modal');
});

@it4joy
Copy link

it4joy commented Aug 16, 2023

I'd rewrite the code listed by @KoderES above to (1st line):

$('#MyModal').off('hide.bs.modal').on('hide.bs.modal', function () { // ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants