Clicking checkbox doesn't change its checked/unchecked status

Clicking checkbox doesn't change its checked/unchecked status

I have a set of checkboxes that trigger events on a page. Clicking a checkbox triggers the event correctly and the checked attribute changes in the page source, but in the rendered browser view the checkbox status remains changed. If I load the page with the checkboxes checked, they always remain checked in the browser view. If I load the page with checkboxes unchecked, they always remain unchecked in the browser view.

If I remove the jquery code the checkboxes work as expected, but obviously don't trigger any events.

I've tested this in both Safari and Firefox with the same results.

  1. <!-- category filter -->
  2. <script type="text/javascript">
  3. $(document).ready(function() {
  4.     $('#toggleList input:checkbox').toggle(  //toggleList is list categories
  5.         function(){  //hiding items of this category
  6.           $(this).removeAttr("checked"); //uncheck
  7.           // do stuff ...        
  8.         },
  9.         function(){ //showing items of this category    
  10.           $(this).attr("checked","checked");
  11.           // do other stuff
  12.         }
  13.     );
  14. });
  15. </script>


  1. <form id="toggleList" action="">
  2.     <input id="category1" name="category1" checked="checked"    
  3.         type="checkbox"><label for="category1">Category 1</label>
  4.     <input id="category2" name="category2" checked="checked"
  5.         type="checkbox"><label for="category2">Category 2</label>
  6.     <input id="category3" name="category3" checked="checked"
  7.         type="checkbox"><label for="category3">Category 3</label>
  8.     <input id="category4" name="category4" checked="checked"
  9.         type="checkbox"><label for="category4">Category 4</label>
  10. </form>            


On another note, I'm having problems with the back button when using the forum. If I am looking through a multi-page search and click on a topic and then click the back button, I go to the first page of the search instead of the last page I was looking at. Similarly, when I first previewed this post and clicked "back" I was returned to the topic list instead of the compose-post page.