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.
- <!-- category filter -->
- <script type="text/javascript">
- $(document).ready(function() {
- $('#toggleList input:checkbox').toggle( //toggleList is list categories
- function(){ //hiding items of this category
- $(this).removeAttr("checked"); //uncheck
- // do stuff ...
- },
- function(){ //showing items of this category
- $(this).attr("checked","checked");
- // do other stuff
- }
- );
- });
- </script>
- <form id="toggleList" action="">
- <input id="category1" name="category1" checked="checked"
- type="checkbox"><label for="category1">Category 1</label>
- <input id="category2" name="category2" checked="checked"
- type="checkbox"><label for="category2">Category 2</label>
- <input id="category3" name="category3" checked="checked"
- type="checkbox"><label for="category3">Category 3</label>
- <input id="category4" name="category4" checked="checked"
- type="checkbox"><label for="category4">Category 4</label>
- </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.