ajax动态增加html节点时,jqm样式未加载出来,须实现refresh操作

在使用js或者jQuery获取控件(例如:button、checkBox、radiobutton等)的值时,也是需要先刷新,否则无法获取到最新的值。

下面列出常用的标签的refresh操作,其他的可以举一反三。
1. Listview的refresh操作:
$('#mylistid').listview('refresh');

2. select menu的refresh操作:
var myselect = $("#myselect");
myselect[0].selectedindex = 2;
myselect.selectmenu("refresh");

3. CheckBoxes的refresh操作:
$("#mycheckBoxid").attr("checked",true).checkBoxradio("refresh");

4. Radio buttons的refresh操作:
$("#myradioid").attr("checked",true).checkBoxradio("refresh");

1.Textarea fields

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

2.Text input fields

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

相关文章

IE6是一个非常老旧的网页浏览器,虽然现在很少人再使用它,但...
PHP中的count()函数是用来计算数组或容器中元素的个数。这个...
使用 AJAX(Asynchronous JavaScript and XML)技术可以在不...
Ajax(Asynchronous JavaScript and XML)是一种用于改进网页...
本文将介绍如何通过AJAX下载Excel文件流。通过AJAX,我们可以...
Ajax是一种用于客户端和服务器之间的异步通信技术。通过Ajax...