jquery mobile 动态加载标签时,无法正常展示样式
原因
在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 动态加载标签时,无法正常展示样式的更多相关文章
- jquery mobile动态加载数据后无法渲染
引自:http://blog.sina.com.cn/s/blog_025270e901016lst.html jquery mobile在动态添加html之后无法渲染控件,无法转换控件的办法! jq ...
- jquery tablesorter 动态加载数据时,排序。过滤失效解决方案
解决方案:重置更新: $("table").trigger("update"); 1 官方 ajax表格数据添加实例: $(document).ready(fu ...
- jquery:为动态加载的元素添加点击事件
jquery:为动态加载的元素添加点击事件 最近在做项目的时候遇到了这样一个问题,给用ajax动态加载出来的内容添加点击事件,但是怎么都触发不了,经过查询试验总结出正确的写法 在jquery1.7之前 ...
- jQuery EasyUI-DataGrid动态加载表头
项目总结—jQuery EasyUI-DataGrid动态加载表头 目录(?)[-] 概要 实现 总结 概要 在前面两篇文章中,我们已经介绍了在jQuery EasyUI-DataGrid ...
- 动态加载Dll时,通过Type生成类对象
原文:动态加载Dll时,通过Type生成类对象 转:http://www.cnblogs.com/zfanlong1314/p/4197383.html "反射"其实就是利用程序集 ...
- JQuery Mobile - 处理图片加载失败!
重点来了:一定要记住error事件不冒泡(如果要用js的方法替换默认出错图片,记得把img的alt属性去掉). 相关的知识点:jquery的ready方法.$("img").err ...
- jquery getScript动态加载JS方法改进详解[转载]
转载自http://www.jb51.net/article/31973.htm 有许多朋友需要使用getScript方法动态加载JS,本文将详细介绍此功能的实现方法 $.getScript( ...
- jquery getScript动态加载JS方法改进详解
有许多朋友需要使用getScript方法动态加载JS,本文将详细介绍此功能的实现方法 $.getScript(url,callback) 这个方法是jquery自身提供的一个用于动态加载js的方法.当 ...
- 项目总结—jQuery EasyUI-DataGrid动态加载表头
http://blog.csdn.net/zwk626542417/article/details/19248747 概要 在前面两篇文章中,我们已经介绍了在jQuery EasyUI-DataGri ...
随机推荐
- ZOJ2748 Free Kick 2017-04-18 20:40 40人阅读 评论(0) 收藏
Free Kick Time Limit: 2 Seconds Memory Limit: 65536 KB In a soccer game, a direct free kick is ...
- MFC中的一般经验之谈----OnInitialUpdate
在MFC程序设计中,按照传统的设计,如果处理WM_PAINT消息,一般会派生一个OnPaint函数,映射到WM_PAINT消息上进行绘图处理.但是很多程序中并没有出现OnPaint,一个OnDraw函 ...
- Oracle EBS应用笔记整理 (转自IT++ flyingkite)
***************************************************** Author: Flyingkite Blog: http://space.itpub. ...
- Radius 认证协议介绍-兼rfc导读
老规矩, 先看维基: 远端用户拨入验证服务(RADIUS, Remote Authentication Dial In User Service)是一个AAA协议,意思就是同时兼顾验证(authent ...
- golang plugin的依赖问题
golang plugin的依赖问题 此文中涉及的plugin运行环境为mac 10.14,go版本为1.11 主要是想讨论一下插件依赖的第三方库的问题. 例子是在https://github.com ...
- 安卓 往SD卡里写文件不能及时更新的问题
我们做Android开发时奖保存图片到SD卡,但是Gallery中不能及时显示 下面我找到了问题所在然后解决了这个问题. 当保存图片后打开gallery时,有的会自动给你刷新,有的不行,这样就导致图片 ...
- 注意力机制(Attention Mechanism)应用——自然语言处理(NLP)
近年来,深度学习的研究越来越深入,在各个领域也都获得了不少突破性的进展.基于注意力(attention)机制的神经网络成为了最近神经网络研究的一个热点,下面是一些基于attention机制的神经网络在 ...
- 486. Predict the Winner
Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from eith ...
- 查看npm全局安装位置
查看npm全局安装位置:npm config get prefix 设置位置:npm config set prefix 填写位置
- ionic 项目 随笔
1,首先 会进入src/index.html, <!-- The polyfills js is generated during the build process --> <sc ...