检查和取消选中JQuery Mobile对话框中的复选框

Jet*_*Pro 9 checkbox dialog jquery-mobile

我试过这段代码来实现我想做的事情.当我在普通的HTML文件中尝试它时,它工作,但当我在我的JQuery Mobile页面中尝试它时,代码对我来说效果不佳.是否有不同的方法或代码来选择JQuery Mobile复选框?

这是我试过的代码:

JAVASCRIPT:

<script>
function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
    if(!document.forms[FormName])
        return;
    var objCheckBoxes = document.forms[FormName].elements[FieldName];
    if(!objCheckBoxes)
        return;
    var countCheckBoxes = objCheckBoxes.length;
    if(!countCheckBoxes)
        objCheckBoxes.checked = CheckValue;
    else
        // set the check value for all check boxes
        for(var i = 0; i < countCheckBoxes; i++)
            objCheckBoxes[i].checked = CheckValue;
}
Run Code Online (Sandbox Code Playgroud)

HTML

<form method="GET" name="myForm" onsubmit="return false;">
<label for="myCheckbox1">
    <input type="checkbox" name="myCheckbox" value="1" id="myCheckbox1">
    I like Britney Spears 
</label>
<br>

<label for="myCheckbox2"><input type="checkbox" name="myCheckbox" value="2" id="myCheckbox2">
    I like Hillary Duff
</label>
<br>

<label for="myCheckbox3"><input type="checkbox" name="myCheckbox" value="3" id="myCheckbox3">
    I like Mandy Moore 
</label>
<br>

<input type="button" onclick="SetAllCheckBoxes('myForm', 'myCheckbox', true);" value="I like them all!">
&nbsp;&nbsp;
<input type="button" onclick="SetAllCheckBoxes('myForm', 'myCheckbox', false);" value="I don't like any of them!">
Run Code Online (Sandbox Code Playgroud)

Jet*_*Pro 25

我不知道在通过JQuery或Javascript取消选中/检查它们之后需要刷新JQuery Mobile的复选框.这是代码:

$("input[type='checkbox']").attr("checked",true).checkboxradio("refresh");
Run Code Online (Sandbox Code Playgroud)

http://api.jquerymobile.com/checkboxradio/#method-refresh