jquerymobile checkbox及时刷新才能获取其准确值

一般登录的时候 都有个记住用户名 记住密码 的两个checkbox 多选框

用jquerymobile 做页面 ,当勾选checkbox 时总是不能获取它正确的值。

解决办法: 

$('input[type="checkbox"]').bind('click',function() {
       $(this).prop('checked').checkboxradio("refresh");   // 绑定事件及时更新checkbox的checked值
  });

如果要用js去改变checkbox的值时也要及时刷新。

$('input [type="checkbox"]').attr('checked',false).checkboxradio("refresh");

$('input [type="checkbox"]').attr('checked',false).checkboxradio("refresh"); 

原因: 因为手动改变它的值后,jquerymobile不能重新渲染。 这样页面显示的值和实际值就不一样了。 (jquerymobile 把form表单元素都隐藏起来,然后用 js添加了一些元素易于美化input, select ,textarea 等元素的效果)

posted @ 2012-04-13 12:33  limanclear  Views(2099)  Comments(1Edit  收藏  举报