Note that there are some explanatory texts on larger screens.

plurals
  1. POPreventing double-click bug with checkbox + label combination
    primarykey
    data
    text
    <p><b>Note this issue may not apply to the general public, as it does not occur unless you're a fast clicker. (150-200ms/click)</b> The reason I'm posting this issue is because my application has a form with 20+ checkboxes next to each other, and after extensive research I've found no related questions on this matter.</p> <p>Here's a simplified scenario - 4 checkboxes and 4 labels, one for each checkbox id:</p> <pre><code>[CB1] Label 1 [CB2] Label 2 [CB3] Label 3 [CB4] Label 4 </code></pre> <p>Assume in each case all CBs are unchecked.</p> <p><b>Expected Behavior:</b></p> <ol> <li>I click on the 4 CBs in rapid succession, they will all become checked. (true)</li> <li>I click on the 4 Labels in rapid succession, and the corresponding CBs become checked. (only true for Chrome, but still not optimal)</li> </ol> <p><b>Actual Behavior for case 2 on Win 7</b> (clicking on labels, because as you know, labels are big and style-able, and the checkboxes are tiny and OS-dependent):</p> <ol> <li>(In Firefox 19) CB2 and CB4 are left unchecked, and while going down the list the word "Label" gets highlighted for Label 2 and Label 4, as if I double-clicked on them.</li> <li>(In Chrome 26) All CBs get correctly checked, but while going down the list the word "Label" gets highlighted for Label 2 and Label 4, as if I double-clicked on them.</li> <li>(In IE 10) CB2 and CB4 are left unchecked, but no false highlighting.</li> </ol> <p>The erroneous behavior could be justified if the clicks are on the same element. In our case those are clearly unique checkboxes with different IDs and Names. So the results are wildly unexpected.</p> <p><b>So my question is:</b></p> <p>Is there a way to <b>disable firing the double click event when I rapidly click on the different checkboxes</b>, but yet still check them with fast single clicks?</p> <p>The closest I've come to is the following script, which interestingly made Firefox behave like Chrome, and Chrome behave like Firefox:</p> <pre><code>jQuery(document).on('dblclick', 'input:checkbox+label', function(event){ console.log('ugly hack fired'); $(this).click(); event.preventDefault(); }) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload