【发布时间】:2013-11-29 01:50:31
【问题描述】:
在我的 phonegap 应用程序中,我使用 jquery mobile。当retrieve the value from my DB 正确填写其他字段时(textbox values are filled correctly)工作except checkbox。我的问题是当DB returns true or false 是no changes in my checkbox 时。我在这个问题上苦苦挣扎了两天,有人建议解决这个问题的解决方案..
我的编码是这样的:
if (results.rows.item(0).checkbox1 == true)
$("#checkbox1").attr('checked', 'checked');
else $("#checkbox1").removeAttr('checked');
也试过这个:
//$('#checkbox1').prop('checked', true).checkboxradio('refresh');
//$("input[id='checkbox1']").attr("checked",results.rows.item(0).checkbox1).checkboxradio("refresh");
已解决: 喜欢
if (results.rows.item(0).checkbox1 === 'true')
$("#checkbox1").attr('checked', 'checked');
else $("#checkbox1").removeAttr('checked');
【问题讨论】:
-
你能在小提琴中重现这个问题吗?
-
@Purus 放入小提琴时,onload 在小提琴中不起作用
-
@Purus 看看这个jsfiddle.net/aravinth/DtY4V
-
您应该在使用cordova 时将其置于deviceready 事件中。 document.addEventListener('deviceready', function() {}, false);
-
在下面编辑了我的回答。请尝试一下
标签: javascript jquery jquery-mobile checkbox cordova