jquery mobile界面数据刷新的实现方法
JQM里面当我们更新了某些页面标签(如: listview, radiobuttons, checkboxes, select menus)里的数据时,必须做refresh操作.
为什么必须做refresh操作操作呢?因为JQM在做页面渲染的时候,为了使样式跟客户端程序相似, 隐藏了原始的标签然后用一些新的标签和自定义的样式来表现原标签,其实新样式的标签已经不是原来的标签,所以更新了数据必须做refresh操作.
各类标签的刷新
1.Textarea fields
$('body').prepend('<textareaid="myTextArea"></textarea>'); $('#myTextArea').textinput();
2.Textinputfields
$('body').prepend('<inputtype="text"id="myTextField"/>'); $('#myTextField').textinput();
3.Buttons
$('body').append('<ahref=""data-theme="e"id="myNewButton">testing</a>'); $('#myNewButton').button();
4.Combobox or select dropdowns
<labelfor="sCountry">Country:</label> <selectname="sCountry"id="sCountry"> <optionvalue="">WhereYouLive:</option> <optionvalue="ad">Andorra</option> <optionvalue="ae">UnitedArabEmirates</option> </select> varmyselect=$("#sCountry"); myselect[0].selectedIndex=3; myselect.selectmenu('refresh');
5.Listviews
<ulid="myList"data-role="listview"data-inset="true"> <li>Acura</li> <li>Audi</li> <li>BMW</li> </ul> $('#mylist').listview('refresh');
6.Slider control
<divdata-role="fieldcontain"> <labelfor="slider-2">Inputslider:</label> <inputtype="range"id="slider-2"value="25"min="0"max="100"/> </div> $('#slider-2').val(80).slider('refresh');
7.Toggle switch
<divdata-role="fieldcontain"> <labelfor="toggle">Flipswitch:</label> <selectname="toggle"id="toggle"data-role="slider"> <optionvalue="off">Off</option> <optionvalue="on">On</option> </select> </div> varmyswitch=$("#toggle"); myswitch[0].selectedIndex=1; myswitch.slider("refresh");
8.Radio buttons
<divdata-role="fieldcontain"> <fieldsetdata-role="controlgroup"data-type="horizontal"> <legend>Layoutview:</legend> <inputtype="radio"name="radio-view"value="list"/> <labelfor="radio-view-a">List</label> <inputtype="radio"name="radio-view"value="grid"/> <labelfor="radio-view-b">Grid</label> <inputtype="radio"name="radio-view"value="gallery"/> <labelfor="radio-view-c">Gallery</label> </fieldset> </div> $("input[value=grid]").attr('checked',true).checkboxradio('refresh');
9.Checkboxes
<divdata-role="fieldcontain"> <fieldsetdata-role="controlgroup"> <legend>Agreetotheterms:</legend> <inputtype="checkbox"name="checkbox-1"id="checkbox-1"class="custom"/> <labelfor="checkbox-1">Iagree</label> </fieldset> </div> $('#checkbox-1').attr('checked',true).checkboxradio('refresh');
以上这篇jquerymobile界面数据刷新的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。