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

serious bug in clickListener (shown.bs.select) #1268

Closed
ARS81 opened this issue Jan 27, 2016 · 2 comments
Closed

serious bug in clickListener (shown.bs.select) #1268

ARS81 opened this issue Jan 27, 2016 · 2 comments

Comments

@ARS81
Copy link

ARS81 commented Jan 27, 2016

A "shown.bs.select" event listener is attached INSIDE the button's click handler, so this gets attached again and again, every time the button is clicked.

https://github.com/silviomoreto/bootstrap-select/blob/56e4f886dc909de82db9327329c2bf0711c7df93/js/bootstrap-select.js#L1062

Debug:

      this.$button.on('click', function () {
        that.setSize();
        that.$element.on('shown.bs.select', function () {
          console.log('XXX');

Now start clicking the button several times to open and close the menu and watch the console how many time XXX is printed.

Watching the code I see the event is only removed when the select is required and in invalid state.

@ARS81
Copy link
Author

ARS81 commented Jan 27, 2016

An easy fix could be to use .one() instead of .on() for the the shown.bs.select event or better moving it outside from the click event handler.

@ARS81
Copy link
Author

ARS81 commented Jan 29, 2016

shown-bs-select

avantika-gupta-jtg pushed a commit to JoshLabs/bootstrap-select that referenced this issue May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant