jquerymobile局部渲染的各種刷新方法小結(jié)
在JQueryMobile頁面在第一次初始化進(jìn)行一次整體渲染,動態(tài)生成的需要局部渲染。
在jquerymobile實(shí)現(xiàn)listview局部渲染的方法:
function queryPublishOrderList(trackOrDealOrInsp,userCode,type,pageNum){
var queryPublishOrderListURL="http://xxx.xxx.xxx.xxx/Myapp/WorkOrderSelByTypeService.svc/WorkOrderSimpSelByType/Json/"+trackOrDealOrInsp+"/"+userCode+"/"+type+"/"+pageNum;
$.ajax({
type: 'get',
dataType : "json",
url: queryPublishOrderListURL,
contentType: 'application/json',
data: [],
success: function(data) {
var sb = new StringBuffer();
$.each(data, function(i,item){
//創(chuàng)建一個(gè)工單列表行對象
sb.append("<ul data-role='listview' data-inset='true' data-theme='c' data-pidertheme='b' >");
sb.append("<li data-role='list-pider'> "+item.work_orders_id+"<span class='ui-li-count'>"+i+"</span></li>");
sb.append("<li><a id='"+item.work_orders_id+"' href='inspectorder.html' >");
sb.append("<p data-role='fieldcontain' ><label for='work_orders_id'>工單號:</label><span id='work_orders_id'>"+item.work_orders_id+"</span></p>");
sb.append("<p data-role='fieldcontain'><label for='founder_na'>創(chuàng)建人:</label><span id='founder_na'>"+item.founder_na+"</span></p>");
sb.append("<p data-role='fieldcontain'><label for='found_time'>創(chuàng)建時(shí)間:</label><span id='found_time'>"+item.found_time+"</span></p>");
sb.append("<p data-role='fieldcontain'><label for='type_na'>工單類型:</label><span id='type_na'>"+item.type_na+"</span><img src='../../images/beforeforward.png' style='float: right'/></p>");
sb.append("<p data-role='fieldcontain'><label for='work_cont'>工單內(nèi)容:</label><span id='work_cont'>"+item.work_cont+"</span></p>");
sb.append("</a></li>");
sb.append("</ul>");
});
var content = sb.toString();
$("#queryList").html(content);
},
error:function(XMLHttpRequest, textStatus, errorThrown){
alert("請求遠(yuǎn)程服務(wù)錯誤!");
},
complete: function() {
$("p[data-role=content] ul").listview();
}
});
}
備注:
listview針對jquerymobile針對listview組件刷新。
$("p[data-role=content] ul").listview();
如果想針對listview內(nèi)部的li刷新可以使用
$("p[data-role=content] ul li").listview("refresh");
否則報(bào)錯誤如下:
jquerymobile listviewcannot call methods on listview prior to initialization; attempted to call method 'refresh'
jquerymobile checkbox及時(shí)刷新才能獲取其準(zhǔn)確值
一般登錄的時(shí)候 都有個(gè)記住用戶名 記住密碼 的兩個(gè)checkbox 多選框
用jquerymobile 做頁面 ,當(dāng)勾選checkbox 時(shí)總是不能獲取它正確的值。
解決辦法:
[code]
$('input[type="checkbox"]').bind('click',function() {
$(this).prop('checked').checkboxradio("refresh"); // 綁定事件及時(shí)更新checkbox的checked值
});
如果要用js去改變checkbox的值時(shí)也要及時(shí)刷新。
$('input [type="checkbox"]').attr('checked',false).checkboxradio("refresh");
$('input [type="checkbox"]').attr('checked',false).checkboxradio("refresh");
原因:因?yàn)槭謩痈淖兯闹岛螅琷querymobile不能重新渲染。 這樣頁面顯示的值和實(shí)際值就不一樣了。 (jquerymobile 把form表單元素都隱藏起來,然后用 js添加了一些元素易于美化input, select ,textarea 等元素的效果)
[/code]
下拉框刷新
$("#selectbox").html(optionList).selectmenu('refresh', true);
復(fù)選按鈕
$("input[type='checkbox']").attr("checked",true).checkboxradio("refresh");
單選按鈕組:
$("input[type='radio']").attr("checked",true).checkboxradio("refresh");
選擇列表::
var myselect = $("select#foo");
myselect[0].selectedIndex = 3;
myselect.selectmenu("refresh");
滑動條
$("input[type=range]").val(60).slider("refresh");
開關(guān) (they use slider):
var myswitch = $("select#bar");
myswitch[0].selectedIndex = 1;
myswitch .slider("refresh");
select 禁用樣式
<select id="select-choice-1" class="mobile-selectmenu-disabled ui-state-disabled" disabled="disabled"name="select-choice-1" aria-disabled="true">
<option value="standard">Standard: 7 day</option>
<option value="rush">Rush: 3 days</option>
<option value="express">Express: next day</option>
<option value="overnight">Overnight</option>
</select>
button禁用樣式
<input class="ui-btn-hidden mobile-button-disabled ui-state-disabled" type="button" disabled="disabled"value="不可用" aria-disabled="true">
相關(guān)文章
jquery實(shí)現(xiàn)點(diǎn)擊按鈕顯示與隱藏效果
這篇文章主要為大家詳細(xì)介紹了jquery實(shí)現(xiàn)點(diǎn)擊按鈕顯示與隱藏效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-04-04用jquery中插件dialog實(shí)現(xiàn)彈框效果實(shí)例代碼
這篇文章介紹了jquery中插件dialog實(shí)現(xiàn)彈框效果實(shí)例代碼,有需要的朋友可以參考一下2013-11-11Jquery異步請求數(shù)據(jù)實(shí)例代碼
Jquery異步請求數(shù)據(jù)實(shí)例代碼,需要的朋友可以參考下。2011-12-12在jquery中的ajax方法怎樣通過JSONP進(jìn)行遠(yuǎn)程調(diào)用
這一節(jié)主要演示下在JQUERY中的ajax方法怎樣通過JSONP進(jìn)行遠(yuǎn)程調(diào)用,需要的朋友可以參考下2014-04-04