问题
I have a form with a few checkboxes. Each time I check/uncheck one box form is submitted. Relevant code:
$("input[name='checkboxgroup']").bind("click",function(e) {
e.preventDefault();
...
...
form.submit();
});
However when I click back button on IE9 it shows all my checkboxes still checked( Expected: checkbox last checked before Back button should've been unchecked)
The backend sends data to check/uncheck checkbox whenever page reloads. I have verified that last checkbox clicked before Back button does have "unchecked" state. However, somehow IE9 sets this checkbox as checked.
Edit
I did some quick checks:
Pre
I have none of the checkboxes checked
I put a break in the Dev tools debugger after e.preventDefault()
statement...but before submit()
to check the state being passed to backend.
In Dev tools console I check $("#checkboxId").attr("checked")
to verify the state as I see
What I observed
verify $("#checkboxId1").attr("checked") = undefined ...(expected as the box is not checked) -->
check this checkbox ---> hits debugger break point --->
verify $("#checkboxId1").attr("checked") is "checked" (as expected) ...but the browser shows checkbox not checked (also expected..preventDefault effect) -->
request goes to backend --> reloads page -->
verify $("#checkboxId1").attr("checked") is checked(as expected) -->
checkbox is now checked (perfect)
...Now the problem:
Having done the above steps...if I click back button
My expectation: should show unchecked checkbox1
Actual results: it still shows checked.
In other browsers: FF, Chrome, Opera, Safari it works per expectations
Any pointers appreciated.
来源:https://stackoverflow.com/questions/22055875/ie9-checkbox-state-change-form-submit-back-button-does-not-show-correct-state