亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

jquerymobile局部渲染的各種刷新方法小結(jié)

 更新時間:2014年03月05日 09:16:48   作者:  
本篇文章主要是對jquerymobile局部渲染的各種刷新方法進(jìn)行了總結(jié)介紹,需要的朋友可以過來參考下,希望對大家有所幫助

在JQueryMobile頁面在第一次初始化進(jìn)行一次整體渲染,動態(tài)生成的需要局部渲染。

在jquerymobile實(shí)現(xiàn)listview局部渲染的方法:

復(fù)制代碼 代碼如下:

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)建一個工單列表行對象 
                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)建時間:</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");

否則報錯誤如下:

jquerymobile listviewcannot call methods on listview prior to initialization; attempted to call method 'refresh'

jquerymobile checkbox及時刷新才能獲取其準(zhǔn)確值

復(fù)制代碼 代碼如下:

一般登錄的時候 都有個記住用戶名 記住密碼 的兩個checkbox 多選框 

用jquerymobile 做頁面 ,當(dāng)勾選checkbox 時總是不能獲取它正確的值。 

解決辦法:   
[code]
$('input[type="checkbox"]').bind('click',function() { 
       $(this).prop('checked').checkboxradio("refresh");   // 綁定事件及時更新checkbox的checked值 
  }); 
 

如果要用js去改變checkbox的值時也要及時刷新。  

$('input [type="checkbox"]').attr('checked',false).checkboxradio("refresh"); 
$('input [type="checkbox"]').attr('checked',false).checkboxradio("refresh");  

原因:因?yàn)槭謩痈淖兯闹岛?,jquerymobile不能重新渲染。 這樣頁面顯示的值和實(shí)際值就不一樣了。 (jquerymobile 把form表單元素都隱藏起來,然后用 js添加了一些元素易于美化input, select ,textarea 等元素的效果)
[/code]
下拉框刷新
復(fù)制代碼 代碼如下:

$("#selectbox").html(optionList).selectmenu('refresh', true); 

復(fù)制代碼 代碼如下:

復(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-disableddisabled="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)文章

最新評論