jQuery Mobile动态添加数据后渲染视图
2016-12-22 00:00
846 查看
jQuery Mobile动态添加数据后渲染视图:
0.Textarea field
1.Text input field
2.button
3.Combobox or select dropdowns
4.最常见的动态添加 listview>li 标签
5.Slider control
6.Toggle switch
7.Radio
8.Checkboxes
【代码位置】
以listview为例:
0.Textarea field
$('body').prepend('<textarea id="myTextArea"></textarea>'); $('#myTextArea').textinput();
1.Text input field
$('body').prepend('<input type="text" id="myTextField" />'); $('#myTextField').textinput();
2.button
$('body').prepend('<input type="text" id="myTextField" />'); $('#myTextField').textinput();
3.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');
4.最常见的动态添加 listview>li 标签
<ul id="myList" data-role="listview" data-inset="true"> <li>A</li> <li>B</li> <li>C</li> </ul> $('#mylist').listview('refresh');
5.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');
6.Toggle switch
<span><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");</span>
7.Radio
<span><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');</span>
8.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');
【代码位置】
以listview为例:
$.ajax({ type:"post", url:'php/json.php', data:{}, datatype:'json', success:function(data){ var ul=$('#myList'); var dic=JSON.parse(data); for(var i=0;i<dic.length;i++){ var li=$('<li></li>'); var a=$('<a></a>'); a.html(dic[i].tname); li.append(a); ul.append(li); $('#myList').listview('refresh');//代码位置 } } });
相关文章推荐
- CI框架给视图添加动态数据
- js动态添加元素之后jquery mobile不能正确渲染解决方法 和 JM checked全选反选
- jquery mobile动态添加元素之后不能正确渲染解决方法说明
- CI框架给视图添加动态数据
- jquery mobile动态加载数据后无法渲染
- jquery mobile动态添加元素之后不能正确渲染解决方法说明
- codeigniter中向视图中动态添加数据
- jquery mobile动态添加元素之后不能正确渲染解决方法说明
- Codeigniter 给视图添加动态数据
- jquery mobile动态添加数据
- arcgis server 学习(二)添加动态渲染层
- ASP.NET2.0中给GridView动态添加模板列并自动绑定数据
- 解决使用AJax往DropDownList中动态添加数据时发生,回发或回调参数无效 的问题
- microsoft visual studio 2005里treeview控件动态添加数据(二级和三级)
- 使用js动态添加文本框 并在后台取文本框数据
- 如何向VFP的数据环境中添加表或视图
- 闲来无聊 随便写写 Javascript 动态添加数据的解决方案
- 想Table服务器控件动态添加数据
- 数据字典和动态性能视图学习小结
- php+javascript+css 实现动态添加数据行