I have a convoluted flag selection event interruption scheme, so I can run some javascript / jQuery code before the click event is completed (i.e. the checkbox is checked).
But I noticed several different actions when applying the code in Chrome (my base browser) and Firefox (used by a smaller set of my users).
In this example script, the sequence of events works fine in Chrome, but if you try the same thing in firefox, the software .trigger('click') does not call the event listener. What for? I searched for it and maybe something related to the $.trigger() method?
My code is:
HTML:
<input type="checkbox" id="foo"> Clicky! <hr> <textarea id="bar"></textarea> <hr> <textarea id="cons"></textarea>
JS (using jQueryUI dialog)
$("#dialog").dialog({ autoOpen: false }); $("#foo").on('mousedown', function(e) { e.preventDefault();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script> <input type="checkbox" id="foo"> Clicky! <hr> <textarea id="bar"></textarea> <hr> <textarea id="cons"></textarea> <div id="dialog"> A modal opens </div>
Update: I simplified my code to simple elements, and I can demonstrate that the behavior is specific to trigger a dialog (or warning or any modal) that breaks the subsequent .trigger ('click') method in firefox.
simplified example
source share