JQM里面当我们更新了某些页面标签(如: listview, radiobuttons, checkboxes, select menus)里的数据时,必须做refresh操作.

为什么必须做refresh操作操作呢?因为JQM在做页面渲染的时候,为了使样式跟客户端程序相似, 隐藏了原始的标签然后用一些新的标签和自定义的样式来表现原标签,其实新样式的标签已经不是原来的标签,所以更新了数据必须做refresh操作.

各类标签的刷新

1.Textarea fields

1
2
$('body').prepend('<textarea id="myTextArea"></textarea>');
$('#myTextArea').textinput();

2.Text input fields

1
2
$('body').prepend('<input type="text" id="myTextField" />');
$('#myTextField').textinput();

3.Buttons

1
2
$('body').append('<a href="" data-theme="e" id="myNewButton">testing</a>');
$('#myNewButton').button();

4.Combobox or select dropdowns

1
2
3
4
5
6
7
8
9
10
<label for="sCountry">Country:</label>
<select name="sCountry" id="sCountry">
<option value="">Where You Live:</option>
<option value="ad">Andorra</option>
<option value="ae">United Arab Emirates</option>
</select>
  
var myselect = $("#sCountry");
myselect[0].selectedIndex = 3;
myselect.selectmenu('refresh');

5.Listviews

1
2
3
4
5
6
7
<ul id="myList" data-role="listview" data-inset="true">
<li>Acura</li>
<li>Audi</li>
<li>BMW</li>
</ul>
  
$('#mylist').listview('refresh');

6.Slider control

1
2
3
4
5
6
<div data-role="fieldcontain">
<label for="slider-2">Input slider:</label>
<input type="range" id="slider-2" value="25" min="0" max="100" />
</div>
  
$('#slider-2').val(80).slider('refresh');

7.Toggle switch

1
2
3
4
5
6
7
8
9
10
11
<div data-role="fieldcontain">
<label for="toggle">Flip switch:</label>
<select name="toggle" id="toggle" data-role="slider">
<option value="off">Off</option>
<option value="on">On</option>
</select>
</div>
  
var myswitch = $("#toggle");
myswitch[0].selectedIndex = 1;
myswitch .slider("refresh");

8.Radio buttons

1
2
3
4
5
6
7
8
9
10
11
12
13
<div data-role="fieldcontain">
    <fieldset data-role="controlgroup" data-type="horizontal">
      <legend>Layout view:</legend>
          <input type="radio" name="radio-view" value="list" />
          <label for="radio-view-a">List</label>
          <input type="radio" name="radio-view" value="grid" />
          <label for="radio-view-b">Grid</label>
          <input type="radio" name="radio-view" value="gallery" />
          <label for="radio-view-c">Gallery</label>
    </fieldset>
</div>
  
$("input[value=grid]").attr('checked',true).checkboxradio('refresh');

9.Checkboxes

1
2
3
4
5
6
7
8
9
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<legend>Agree to the terms:</legend>
<input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" />
<label for="checkbox-1">I agree</label>
</fieldset>
</div>
  
$('#checkbox-1').attr('checked',true).checkboxradio('refresh');

JQM动态渲染各种问题的解决办法:

1、select动态渲染——“cannot call methods on selectmenu prior to initialization; attempted to call”

 $('#selectID').selectmenu();
$('#selectID').selectmenu("refresh");

jquery mobile界面数据刷新的更多相关文章

  1. jquery mobile 请求数据方法执行时显示加载中提示框

    在jquery mobile开发中,经常需要调用ajax方法,异步获取数据,如果异步获取数据方法由于网速等等的原因,会有一个反应时间,如果能在点击按钮后数据处理期间,给一个正在加载的提示,客户体验会更 ...

  2. 分享自制的13套 JQuery Mobile 界面主题(追加4套新款)

    15套整合在一起的,其中2套官方+13套自制,款款精致,方便移动开发. 字体默认为微软雅黑. 适配于 JQuery Mobile 1.4.3 下载地址:http://files.cnblogs.com ...

  3. jquery完成界面无刷新加载登陆注册

    昨天公司说官网的登陆注册每次要跳转到另一个界面,能不能做一个简单的,在界面弹出一个框框登陆,我想了想做了这么一个案例,大家来看看成不成 贴上代码,实现了在同一个弹出窗上加载了登陆注册功能!可自由点击! ...

  4. jquery mobile各类组件刷新方法

      1.Combobox or select dropdowns var myselect = $("#sCountry"); myselect[0].selectedIndex ...

  5. Jquery mobile 新手问题总汇

    1页面缩放显示问题 问题描述: 页面似乎被缩小了,屏幕太宽了. 解决办法: 在head标签内加入: <meta name="viewport" content="w ...

  6. [转载]Jquery mobile 新手问题总汇

    原文链接:http://www.wglong.com/main/artical!details?id=4 此文章将会持续更新,主要收录一些新手比较常见的问题. 欢迎 向我推荐比较典型的常见问题,我会记 ...

  7. Jquery Mobile实例--利用优酷JSON接口读取视频数据

    本文将介绍,如何利用JqueryMobile调用优酷API JSON接口显示视频数据. (1)注册用户接口. 首页,到 http://open.youku.com 注册一个账户,并通过验证.然后找到A ...

  8. jquery mobile Checkbox动态添加刷新及事件绑定

    jquery mobile Checkbox动态添加刷新及事件绑定 在微信项目中,涉及到一个多选功能.数据来自后台数据库,需要动态加载. 项目结构:微信api+web app.使用jquery mob ...

  9. Jquery Mobile 动态添加元素然后刷新 转

    Jquery Mobile 动态添加元素然后刷新 (2013-05-09 12:39:05) 转载▼ 标签: it 分类: Mobile jquery 表单元素每一个元素都有自己刷新的方法,每当改变它 ...

随机推荐

  1. 学习PHP第一天-----简单登录

    <!DOCTYPE html> <html> <head> <title>初级登录界面</title> </head> < ...

  2. jquery中prop()方法和attr()方法的区别浅析

    官方例举的例子感觉和attr()差不多,也不知道有什么区别,既然有了prop()这个新方法,不可能没用吧,那什么时候该用attr(),什么时候该用prop()呢 jquery1.6中新加了一个方法pr ...

  3. Update UI from an asynchronous thread

    One of the most common tasks you need to perform in a Windows Phone application is updating the UI f ...

  4. Background agent

    Periodic Task Periodic agents run for a small amount of time on a regular recurring interval. Typica ...

  5. 第二章 Odoo的安装与部署

    Odoo的官方推荐是Ubuntu Server,所以,我们这里也以Ubuntu Server为例.当然,其他系统也是可以的,只不过安装起来相比Ubuntu 会显得稍微折腾,限于篇幅,本书不对其他系统的 ...

  6. ASCII值对照表

    说明:这里的ascii的值是十进制的 ASCII值 控制字符 ASCII值 控制字符 ASCII值 控制字符 ASCII值 控制字符 0 NUT 32 (space) 64 @ 96 . 1 SOH ...

  7. 将文件系统数据库迁移到ASM中

    使用裸设备配置ASM实例 http://www.cnblogs.com/myrunning/p/4270849.html 1.查看我们创建的磁盘组 [oracle@std ~]$ export ORA ...

  8. Datatable转换Json

    #region Datatable转换为Json        /// <summary>         /// Datatable转换为Json         /// </su ...

  9. BizTalk开发系列(十四) XML空白字符(WhiteSpace)

    最近在做一个BizTalk项目,对XML文件的处理很复杂.本来是想找有没有方法可以一次性去除XML文件中节点和属性的值的空格.但是找了很久没有看到相关的方法.如果有知道该方法的麻烦跟我讲一下:cbcy ...

  10. 【iCore3 双核心板】例程七:WWDG看门狗实验——复位ARM

    .. 实验指导书及代码包下载: http://pan.baidu.com/s/1qWEK7fQ iCore3 购买链接: https://item.taobao.com/item.htm?id=524 ...