vendredi 24 avril 2015

Adding a dynamic div to local storage checkbox - jquery /jquery mobile

I have a jQuery mobile web app that uses dynamic lists to bookmark classes based on checkboxes using show/hide. I was using cookies but could not transfer them in phone gap.

I managed to get my checkboxes to local storage but how can I now add a the show/hid list to that? IE click on the checkbox and then pull that value from/with the local storage to create the new div.

Here is my local storage check box as is:

$(function () {
    var data = localStorage.getItem("checkbox-mini-c103");

    if (data !== null) {
        $("input[name='checkbox-mini-c103']").attr("checked", "checked");
    }
});

$("input[name='checkbox-mini-c103']").click(function () {

    if ($(this).is(":checked")) {
        localStorage.setItem("checkbox-mini-c103", $(this).val());
    } else {
        localStorage.removeItem("checkbox-mini-c103");
    }
});




Aucun commentaire:

Enregistrer un commentaire