我正在使用另一个页面上的链接列表调用页面(请参阅下面的代码).像这样的清单
<ul data-role="listview" data-theme="g">
<li><a href="test.html">test</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
以下代码是test.html页面.
我在这些页面上使用jquery mobile.通过单击链接加载页面时,只有前3个复选框后面的复选框似乎正确刷新(显示为选中).前三个复选框始终显示为未选中,其选中的值设置为false.不寻常的是,如果我在将复选框设置为true的语句之后放置if语句,则复选框选中的值的计算结果为true,但在呈现的页面上显示为false,并且您在元素区域中查看选中的值网络检查员.刷新页面时(使用F5或地址栏附近的刷新按钮)复选框会按预期刷新.任何帮助将不胜感激.虽然下面的示例代码似乎只是将所有复选框设置为选中的值,但我真的(在我的实际页面中)根据记录集中的数据设置它们的值,因此我不能将质量设置设置为true并刷新.我必须遍历记录集并相应地设置复选框值.下面的代码只是我所遇到的错误的简单再现.谢谢!
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Checkbox</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1">
<link rel="stylesheet" href="jqm1/jquery.mobile.structure-1.0.1.min.css" />
<script src="jqm/jquery-1.7.1.min.js"></script>
<script src="jqm/jquery.mobile-1.0.1.min.js"></script>
</head>
<body>
<div id="loadCB" data-role="page">
<script type="text/javascript">
$("#loadCB").live('pageinit', function() {
// do something here...
for (i=0;i<=5;i++)
{
$("#checkbox-"+i).prop("checked", true);
$("#checkbox-"+i).prop("checked", true).checkboxradio("refresh");
}
});
</script>
<article data-role="content">
<form id="frmR">
<input type="checkbox" name="checkbox-0" id="checkbox-0" class="custom" value="0"/>
<label for="checkbox-0">checkbox-0</label>
<input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" value="1"/>
<label for="checkbox-1">checkbox-1</label>
<input type="checkbox" name="checkbox-2" id="checkbox-2" class="custom" …Run Code Online (Sandbox Code Playgroud)