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

前端之家收集整理的这篇文章主要介绍了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');
原文链接:https://www.f2er.com/ajax/163041.html

猜你在找的Ajax相关文章