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

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

各类标签的刷新

1.Textarea fields

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

-------------------------------------------------------------
2.Text input fields

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

-------------------------------------------------------------

3.Buttons

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

-------------------------------------------------------------

4.Combobox or select dropdowns

<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

<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

<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

<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

<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

<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');

-------------------------------------------------------------

10.controlgroup
            
$("#fieldNextNode").trigger('create');//发生cannot call methods on checkboxradio prior to initialization; attempted to call method 'refresh'……错误时
$("#fieldNextNode").controlgroup("refresh");

jquery mobile各类标签的refresh的更多相关文章

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

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

  2. Jquery mobile 新手问题总汇

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

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

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

  4. [转]jQuery Mobile动态刷新页面样式

    本文转自:http://blog.csdn.net/zht666/article/details/8560765 当我们使用Ajax或者javascript动态在页面上添加元素后,如添加select控 ...

  5. bootstrap和jquery mobile的对比

    最近一直在研究bootstrap这东西,确实是个好的框架,但是诸多优势背后也隐藏着一些不好的地方,对此,我把它和另一套响应式框架jquery mobile做了一下对比,我的总结如下:    1.boo ...

  6. JQuery Mobile - 解决动态更新页面内容,CSS失效问题!

    今天编写JQuery Mobile程序,需要对数组数据动态创建,并且每条数据对应一个复选框,于是我很顺利写了一个Demo,当我运行时候发现,和我期望的不一样!复选框确实创建出来了,但是却没有CSS效果 ...

  7. jquery mobile 动态加载标签时,无法正常展示样式

    原因 在chrome中审查元素,发现其增加了很多没有直接写在页面上的标签和样式.页面标签首先经过jquery.mobile-1.4.5.min.js的处理,添加了许多标签,然后再用css布局 解决方案 ...

  8. jQuery Mobile(jqm)button的隐藏和显示,包含a标签,圆角和非圆角button

    在移动互联网时代,HTML5开发越来越收到欢迎. 于是各种HTML5的框架都出来了.因为对于jquery的熟悉,jquery mobile 为多数人选择学习的对象.我也是众多追求者之中的一个.近期一直 ...

  9. jQuery Mobile动态刷新页面样式

    当我们使用Ajax或者javascript动态在页面上添加元素后,如添加select控件的option元素,添加ul的li元素.添加之后我们会发现,它们显示的样式不是jQuery Mobile的炫酷样 ...

随机推荐

  1. [LeetCode]Delete and Earn题解(动态规划)

    Delete and Earn Given an array nums of integers, you can perform operations on the array. In each op ...

  2. HDU 3306 Another kind of Fibonacci ---构造矩阵***

    Another kind of Fibonacci Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Jav ...

  3. uestc 1072 a ^ b

    a ^ b Time Limit: 1000 ms Memory Limit: 65535 kB Solved: 334 Tried: 2153 Description 求a的b次方后四位.   In ...

  4. 10、springboot之集成druid

    在pom.xml中添加 <dependency> <groupId>com.alibaba</groupId> <artifactId>druid< ...

  5. C#学习笔记-外观模式

    题目:股民买卖股票 实现: static void Main(string[] args) { Stock1 gu1 = new Stock1(); Stock2 gu2 = new Stock2() ...

  6. 【零基础学习FreeRTOS嵌入式系统】之一:FreeRTOS环境搭建

    [零基础学习FreeRTOS嵌入式系统]之一:FreeRTOS环境搭建 一:FreeRTOS系统下载 在官网上https://www.freertos.org/,找到下载入口. 或直接进入下载地址ht ...

  7. ionCube 安装

    有些程序在php环境下运行需要安装ionCube Loader的扩展支持,得到如下提示 Site error: the ionCube PHP Loader needs to be installed ...

  8. CSS属性之margin

    0.对自身可视宽度的影响 1>改变处于标准文档流中,未设置width值的block元素的可视宽度 在标准文档流中,对于没有设置宽度的block元素,当其具有内容或者设置高度后,其自身宽度为父元素 ...

  9. line-height属性的深入了解

    line-height属性的细节与大多数CSS属性不同,line-height支持属性值设置为无单位的数字.有无单位在子元素继承属性时有微妙的不同. 语法line-height: normal | & ...

  10. js解决千分符问题[收藏下]

    //js数字千分符处理 function commafy(num) { num = num + ""; var re = /(-?\d+)(\d{3})/ while (re.te ...