原因

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

解决方案

1.将jquery.mobile-1.4.5.min.js处理后的样式动态添加,即将chrome中审查元素得到的完整元素及样式复制下来,动态添加

缺点:代码很多,而且加了很多奇怪样式和各种标签

2.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");

参考资料:

http://blog.csdn.net/lgd5979/article/details/7161339

jquery mobile 动态加载标签时,无法正常展示样式的更多相关文章

  1. jquery mobile动态加载数据后无法渲染

    引自:http://blog.sina.com.cn/s/blog_025270e901016lst.html jquery mobile在动态添加html之后无法渲染控件,无法转换控件的办法! jq ...

  2. jquery tablesorter 动态加载数据时,排序。过滤失效解决方案

    解决方案:重置更新: $("table").trigger("update"); 1 官方 ajax表格数据添加实例: $(document).ready(fu ...

  3. jquery:为动态加载的元素添加点击事件

    jquery:为动态加载的元素添加点击事件 最近在做项目的时候遇到了这样一个问题,给用ajax动态加载出来的内容添加点击事件,但是怎么都触发不了,经过查询试验总结出正确的写法 在jquery1.7之前 ...

  4. jQuery EasyUI-DataGrid动态加载表头

    项目总结—jQuery EasyUI-DataGrid动态加载表头     目录(?)[-] 概要 实现 总结   概要 在前面两篇文章中,我们已经介绍了在jQuery EasyUI-DataGrid ...

  5. 动态加载Dll时,通过Type生成类对象

    原文:动态加载Dll时,通过Type生成类对象 转:http://www.cnblogs.com/zfanlong1314/p/4197383.html "反射"其实就是利用程序集 ...

  6. JQuery Mobile - 处理图片加载失败!

    重点来了:一定要记住error事件不冒泡(如果要用js的方法替换默认出错图片,记得把img的alt属性去掉). 相关的知识点:jquery的ready方法.$("img").err ...

  7. jquery getScript动态加载JS方法改进详解[转载]

    转载自http://www.jb51.net/article/31973.htm 有许多朋友需要使用getScript方法动态加载JS,本文将详细介绍此功能的实现方法     $.getScript( ...

  8. jquery getScript动态加载JS方法改进详解

    有许多朋友需要使用getScript方法动态加载JS,本文将详细介绍此功能的实现方法 $.getScript(url,callback) 这个方法是jquery自身提供的一个用于动态加载js的方法.当 ...

  9. 项目总结—jQuery EasyUI-DataGrid动态加载表头

    http://blog.csdn.net/zwk626542417/article/details/19248747 概要 在前面两篇文章中,我们已经介绍了在jQuery EasyUI-DataGri ...

随机推荐

  1. 对ConditionQueue和锁的理解

    1. 什么时候使用conditionQueue 使用conditionQueue的一个最基本的条件是,操作和状态相关,而且是多线程同时访问的状态. 也就是说在使用conditionQueue的时候, ...

  2. ubuntu解压文件命令大全

    ubuntu 下rar解压工具安装方法: 压缩功能 安装 sudo apt-get install rar 卸载 sudo apt-get remove rar 解压功能 安装 sudo apt-ge ...

  3. 用U盘安装Ubuntu主系统

    用U盘安装Ubuntu主系统 0. 学习Ubuntu系统的的动机 ubuntu系统的内核是linux系统,通过Ubuntu的学习,掌握lInux服务器搭建!!!! 硬件要求:闲置的笔记本  +  U盘 ...

  4. R12 查询EBS用户相关SQL

    --R12查询EBS在线用户SQL SELECT U.USER_NAME,       APP.APPLICATION_SHORT_NAME,       FAT.APPLICATION_NAME,  ...

  5. 作业 c++编写

    1.第一版本程序Prog1:+ 给定一个数组,实现数组元素求和:,具体要求:实现对一维数组(a[100])的所有元素相加运算.+ 数据准备:a)数组长度:100:b)数组数据来源:实验数据A列:1~1 ...

  6. Android studio 报错 installation failed with message failed to finalize session:INSTALL_FAILED_INVALID_APK 解决方法

    解决方案: File->Setting->Build->Instant Run

  7. django 的 ajax 方式上传图片

    页面代码: <html>     <!-- 引入相关的js文件,相对路径  -->     <script type="text/javascript" ...

  8. roadflow asp.net工作流自定义表单

    在roadflow表单设计器不能满足很复杂的业务需求的时候,可以采用自定义表单(即表单页面自己做). 自定义表单就是自己写一个页面,包含控制器视图,然后将这个页面挂到流程上进行审批. 自定义表单分为以 ...

  9. kolla-ansible 重新部署 ceph 遇到的问题

    问题 TASK [ceph : Fetching Ceph keyrings] ******************************************* fatal: [controll ...

  10. 486. Predict the Winner

    Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from eith ...