Help setting modulation flags. I have this page:
<!DOCTYPE html> <html> <head> <title></title> <script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script> <script type="text/javascript"> $(function() { $('<div><input type="checkbox" name="makeHidden" id="makeHidden" checked="checked" />Make Hidden</div>').appendTo('body'); $('<div id="displayer" style="display:none;">Was Hidden</div>').appendTo('body'); $('#makeHidden').click(function() { var isChecked = $(this).is(':checked'); if (isChecked) { $('#displayer').hide(); } else { $('#displayer').show(); } return false; }); }); </script> </head> <body> </body> </html>
This does not work due to return false; in the click handler. If I remove it, it works fine. The problem is that if I pulled the click function into my own function and unit test with qunit, it will not work without return false;
[EDIT] Using @patrick answers my results:
Firefox:
- A manual test for a toy is good.
- Unit tests are good.
- Manually checking a production application is good.
Internet Explorer:
- A manual test for a toy is a failure.
- Unit tests are good.
- A manual test of a production application is a failure.
Internet Explorer requires first, with one click. then two clicks are required.
I thought jQuery is an abstraction of browsers?
Do I have to override the behavior of the entire field to solve?
In my unit tests, this is how I do the user flag simulation:
$(':input[name=shipToNotActive]').removeAttr('checked'); $('#shipToNotActive').change();
and:
$(':input[name=shipToNotActive]').attr('checked', 'checked'); $('#shipToNotActive').change();
source share