Skip to content
Advertisement

Why Bootstrap 3 Collapse is not synchronized with checkbox state on double click?

According to this question: “Twitter Bootstrap 3 collapse when checkbox checked” i’ve tried this solution, because it is simple and clean.

http://jsfiddle.net/L0h3s7uf/1/

JavaScript

But with this “solution” you have a problem. If you click the checkbox too fast, the area is collapsed but the checkbox is checked.

How can i prevent this double clicking problem?

I am using:

  • Bootstrap 3
  • jQuery 3.1.1

Advertisement

Answer

Since there is no double click handling in bootstrap for toggle specially, so I come up with a special work around to make double click in sync.

I just removed data-toggle="collapse" attribute, added #testCheckBox id to checkbox’s parent div and I did some custom script which detect if double click or single click then validate the checkbox values and toggle on their bases:

JavaScript

demo: https://jsbin.com/ciloliweto/edit?html,output

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement