I am trying to use unobtrusive-ajax to allow a site to update its contents as AJAX if JavaScript is available and as static pages if not. I'd like to support the browser's Back
button moving backwards in history.
I am using JavaScript's history API to manipulate the browser history as a user navigates the website. I am storing both the HTML (through innerHTML
) and the current state of the DOM (through JQuery's serialize
method) in the history object. When the user hits Back
, the HTML and then DOM are restored from the cached HTML and serialized DOM, respectively.
However, I'm losing the information about checkboxes that were selected when the page loaded ("checked"="checked"
) but that the user unselected.
Per the JQuery docs at https://api.jquery.com/serialize/
Values from checkboxes and radio buttons (inputs of type "radio" or "checkbox") are included only if they are checked.
"Values" here refers to the checked state, not the value
of the checkbox.
Is this a mis-design? Shouldn't it include the checked value when it differs from the HTML?
Are there other properties on other elements that are conditionally serialized?