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. IDictionary<TKey, TValue> vs. IDictionary

    Enumerating directly over an IDictionary<TKey,TValue>returns a sequence of  KeyValuePair struc ...

  2. RecyclerView使用时遇到的问题

    一.概述 二.常见问题: 1.如何为RecyclerView的Item设置点击事件? 1.1 问题描述 类似于下列方法 RecyclerView.setOnItemClickListener(OnCl ...

  3. Struts2整理+课堂代码+注意事项

    1.在Struts配置文件的<package   中的 namespace默认是namesopace="/". 当生成namespace=“abc/”(abc是自己定义的,类 ...

  4. java.lang.UnsupportedClassVersionError: TwoSum : Unsupported major.minor version 52.0

    编译的版本比运行的版本高. 两台电脑,一个装的是jdk1.7,另一个是1.8,在1.8上运行之后,上传到github然后1.7的拉下来,再运行出现了上述错误. 解决方式:设置如下

  5. HTML5 表单属性

    form 属性 form 属性规定输入域所属的一个或多个表单. 注释:form 属性适用于所有 <input> 标签的类型. form 属性必须引用所属表单的 id: 实例 <for ...

  6. Ajax Post 与 Get 实例

    Ajax的POST实例,index.html <html> <head> <script type="text/javascript"> fun ...

  7. IOS第一天多线程-04GCD通信

    **** #define HMGlobalQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) #define HMM ...

  8. WPF 打开文件、文件夹

    打开文件代码: OpenFileDialog openFileDialog = new OpenFileDialog();            openFileDialog.Title = &quo ...

  9. Final-阶段站立会议5

    组名:天天向上 组长:王森 组员:张政.张金生.林莉.胡丽娜 代码地址:HTTPS:https://git.coding.net/jx8zjs/llk.git SSH:git@git.coding.n ...

  10. libgdx 常见问题

    libgdx assets file not found Select Run -> Edit Configurations from the menu In the "Working ...