Jquery Mobile checkbox-list does not update when adding items and “refreshing” the script to style it

后端 未结 1 960
说谎
说谎 2021-01-25 09:51

It is very easy to add a checkbox list in JQuery Mobile, the scripts automatically style/change the following html and give it functionality:

1条回答
  •  半阙折子戏
    2021-01-25 10:37

    Don't panic. As you are using jQuery Mobile, this also could be done very easy. First of all, you should set the structure of your page:

    ...here goes your fieldset

    You should append the new checkbox inside the controlgroup container:

    $(document).on("pagecreate", "#page-1", function() {
        var item5 = $(""), 
            liste = $("#liste");
        liste.controlgroup("container").append(item5);
        $(item5[1]).checkboxradio();
        liste.controlgroup("refresh");
    });
    

    BTW, you may also use $(document).on("pagecreate") instead of $(document).ready.

    0 讨论(0)
提交回复
热议问题