Home Web Front-end JS Tutorial Summary of various refresh methods for jquerymobile partial rendering_jquery

Summary of various refresh methods for jquerymobile partial rendering_jquery

May 16, 2016 pm 04:57 PM
jquery mobile refresh

On the JQueryMobile page, an overall rendering is performed during the first initialization. Dynamically generated pages require partial rendering.

How to implement partial rendering of listview in jquerymobile:

Copy the code The code is as follows:

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){ 
                 //创建一个工单列表行对象 
                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'>创建人:</label><span id='founder_na'>" item.founder_na "</span></p>"); 
                sb.append("<p data-role='fieldcontain'><label for='found_time'>创建时间:</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'>工单内容:</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("请求远程服务错误!"); 
        }, 
        complete: function() {     
              $("p[data-role=content] ul").listview();           
        }   
    }); 
}

Remarks:

Listview refreshes the listview component for jquerymobile.

$("p[data-role=content] ul").listview();

If you want to refresh the li inside the listview, you can use

$("p[data-role=content] ul li").listview("refresh");

Otherwise the error will be reported as follows:

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

Jquerymobile checkbox needs to be refreshed in time to obtain its accurate value

Copy code The code is as follows:

Generally, when logging in, there are two checkboxes for remembering username and password.

Using jquerymobile to make the page, when the checkbox is checked, it cannot always get its correct value.

Solution:
[code]
$('input[type="checkbox"]').bind('click',function() {
$(this). prop('checked').checkboxradio("refresh"); // Bind events to update the checked value of the checkbox in time
});


If you want to use js to change the checkbox The value must also be refreshed in time.

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

Cause: jquerymobile cannot re-render after manually changing its value. In this way, the value displayed on the page is different from the actual value. (jquerymobile hides all form elements, and then uses js to add some elements to beautify the effects of input, select, textarea and other elements)
[/code]
Drop-down box refresh
Copy code The code is as follows:

$("#selectbox").html(optionList).selectmenu('refresh', true ); 🎜>$("input[type='checkbox']").attr("checked",true).checkboxradio("refresh");
Radio button group:
$("input [type='radio']").attr("checked",true).checkboxradio("refresh"); $("input[type=range]").val( 60).slider("refresh");

Switch (they use slider):
var myswitch = $("select#bar");
myswitch[0].selectedIndex = 1;
myswitch .slider("refresh");



select disable style

<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 disabled style<input class="ui-btn-hidden mobile-button-disabled
ui-state- disabled
" type="button"
disabled="disabled"
value="not available"
aria-disabled="true">

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

F5 refresh key not working in Windows 11 F5 refresh key not working in Windows 11 Mar 14, 2024 pm 01:01 PM

F5 refresh key not working in Windows 11

Detailed explanation of jQuery reference methods: Quick start guide Detailed explanation of jQuery reference methods: Quick start guide Feb 27, 2024 pm 06:45 PM

Detailed explanation of jQuery reference methods: Quick start guide

How to use PUT request method in jQuery? How to use PUT request method in jQuery? Feb 28, 2024 pm 03:12 PM

How to use PUT request method in jQuery?

Yaber T2 (Plus): Compact projector with Full HD resolution, battery, JBL sound and smart functions Yaber T2 (Plus): Compact projector with Full HD resolution, battery, JBL sound and smart functions Jun 27, 2024 am 10:31 AM

Yaber T2 (Plus): Compact projector with Full HD resolution, battery, JBL sound and smart functions

How to remove the height attribute of an element with jQuery? How to remove the height attribute of an element with jQuery? Feb 28, 2024 am 08:39 AM

How to remove the height attribute of an element with jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

jQuery Tips: Quickly modify the text of all a tags on the page

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Use jQuery to modify the text content of all a tags

What is Helium Mobile? Comprehensive interpretation of Mobile tokens What is Helium Mobile? Comprehensive interpretation of Mobile tokens Jul 17, 2024 pm 12:57 PM

What is Helium Mobile? Comprehensive interpretation of Mobile tokens

See all articles