I have a checkbox in my page that is checked by default. I try to use LocalStorage and save the value there if a user changes it.
This is what I have done:
<script language="javascript" type="text/javascript">
jQuery(document).ready(function ($) {
$('#togglelist').prop('checked', localStorage.ListCheckbox);
$("#togglelist").change(function () {
localStorage.ListCheckbox = $('#togglelist').prop('checked');
});
</script>
I can see on the developer console the value changing while clicking on the checkbox. Also, if I leave it unchecked (false), on the next page load, the local storage has false as value, but the checkbox is still checked.
Edit: I cannot use the checkboxradio('refresh')
since I don't have the JQM.
Aucun commentaire:
Enregistrer un commentaire