On the JQueryMobile page, perform an overall rendering at the first initialization. Dynamic rendering is required.
How to implement partial rendering of listview in jquerymobile:
Java code
- 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 ){
- // Create a single-column table row object
- Sb. append ("<ul data-role = 'listview 'data-inset = 'true' data-theme = 'C' data-dividertheme = 'B'> ");
- Sb. append ("<li data-role = 'LIST-divider '>" + 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 ("<div data-role = 'fieldcontain'> <label for = 'work _ orders_id '> Ticket No: </label> <span id = 'work _ orders_id '> "+ item. work_orders_id + "</span> </div> ");
- Sb. append ("<div data-role = 'fieldcontain'> <label for = 'founder _ Na'> Creator: </label> <span id = 'founder _ Na'> "+ item. founder_na + "</span> </div> ");
- Sb. append ("<div data-role = 'fieldcontain'> <label for = 'found _ time'> Creation time: </label> <span id = 'found _ time'> "+ item. found_time + "</span> </div> ");
- Sb. append ("<div data-role = 'fieldcontain'> <label for = 'Type _ Na'> ticket type: </label> <span id = 'Type _ Na'> "+ item. type_na + "</span> </div> ");
- Sb. append ("<div data-role = 'fieldcontain'> <label for = 'work _ cont'> ticket content: </label> <span id = 'work _ cont'> "+ item. work_cont + "</span> </div> ");
- Sb. append ("</a> </li> ");
- Sb. append ("</ul> ");
- });
- Var content = sb. toString ();
- $ ("# QueryList" Contents .html (content );
- },
- Error: function (XMLHttpRequest, textStatus, errorThrown ){
- Alert ("remote service request error! ");
- },
- Complete: function (){
- $ ("Div [data-role = content] ul"). listview ();
- }
- });
- }
Note:
Listview refreshes the listview component for jquerymobile.
$ ("Div [data-role = content] ul"). listview ();
If you want to refresh the internal li of listview, you can use
$ ("Div [data-role = content] ul li"). listview ("refresh ");
Otherwise, the following error is reported:
Jquerymobile listviewcannot call methods on listview prior to initialization; attempted to call method 'refresh'
Jquerymobile checkbox can be refreshed in time to obtain its accurate value.
Java code
- Generally, when you log on, there is a two checkbox multiple selection box that remembers the user name and password.
- Jquerymobile is used as a page. When checkbox is checked, the correct value cannot be obtained.
- Solution:
- $ ('Input [type = "checkbox"] '). bind ('click', function (){
- $ (This). prop ('checked'). checkboxradio ("refresh"); // bind an event to promptly update the checked value of the checkbox
- });
- If you want to use js to change the checkbox value, refresh it in time.
- $ ('Input [type = "checkbox"] '). attr ('checked', false). checkboxradio ("refresh ");
- $ ('Input [type = "checkbox"] '). attr ('checked', false). checkboxradio ("refresh ");
- Cause: After Manually changing its value, jquerymobile cannot re-render it. In this way, the value displayed on the page is different from the actual value. (Jquerymobile hides all form elements, and then adds some elements in js to make it easy to beautify the effects of input, select, textarea, and other elements)
Refresh Java code in the drop-down box
- $ ("# Selectbox" pai.html (optionList). selectmenu ('refresh', true );
Java code
- Check button
- $ ("Input [type = 'checkbox']"). attr ("checked", true). checkboxradio ("refresh ");
- Single button group:
- $ ("Input [type = 'radio']"). attr ("checked", true). checkboxradio ("refresh ");
- Select list ::
- Var myselect = $ ("select # foo ");
- Myselect [0]. selectedIndex = 3;
- Myselect. selectmenu ("refresh ");
- Slide
- $ ("Input [type = range]"). val (60). slider ("refresh ");
- Switch (they use slider ):
- Var myswitch = $ ("select # bar ");
- Myswitch [0]. selectedIndex = 1;
- Myswitch. slider ("refresh ");
Select disabled 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 days </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 = "unavailable" aria-disabled = "true">