在JQueryMobile页面在第一次初始化进行一次整体渲染,动态生成的需要局部渲染。

在jquerymobile实现listview局部渲染的方法:

  1. function queryPublishOrderList(trackOrDealOrInsp,userCode,type,pageNum){
  2. var queryPublishOrderListURL="http://xxx.xxx.xxx.xxx/Myapp/WorkOrderSelByTypeService.svc/WorkOrderSimpSelByType/Json/"+trackOrDealOrInsp+"/"+userCode+"/"+type+"/"+pageNum;
  3. $.ajax({
  4. type: 'get',
  5. dataType : "json",
  6. url: queryPublishOrderListURL,
  7. contentType: 'application/json',
  8. data: [],
  9. success: function(data) {
  10. var sb = new StringBuffer();
  11. $.each(data, function(i,item){
  12. //创建一个工单列表行对象
  13. sb.append("<ul data-role='listview' data-inset='true' data-theme='c' data-dividertheme='b' >");
  14. sb.append("<li data-role='list-divider'> "+item.work_orders_id+"<span class='ui-li-count'>"+i+"</span></li>");
  15. sb.append("<li><a id='"+item.work_orders_id+"' href='inspectorder.html' >");
  16. sb.append("<div data-role='fieldcontain' ><label for='work_orders_id'>工单号:</label><span id='work_orders_id'>"+item.work_orders_id+"</span></div>");
  17. sb.append("<div data-role='fieldcontain'><label for='founder_na'>创建人:</label><span id='founder_na'>"+item.founder_na+"</span></div>");
  18. sb.append("<div data-role='fieldcontain'><label for='found_time'>创建时间:</label><span id='found_time'>"+item.found_time+"</span></div>");
  19. sb.append("<div data-role='fieldcontain'><label for='type_na'>工单类型:</label><span id='type_na'>"+item.type_na+"</span><img  src='../../images/beforeforward.png' style='float: right'/></div>");
  20. sb.append("<div data-role='fieldcontain'><label  for='work_cont'>工单内容:</label><span id='work_cont'>"+item.work_cont+"</span></div>");
  21. sb.append("</a></li>");
  22. sb.append("</ul>");
  23. });
  24. var content = sb.toString();
  25. $("#queryList").html(content);
  26. },
  27. error:function(XMLHttpRequest, textStatus, errorThrown){
  28. alert("请求远程服务错误!");
  29. },
  30. complete: function() {
  31. $("div[data-role=content] ul").listview();
  32. }
  33. });
  34. }

备注:

listview针对jquerymobile针对listview组件刷新。

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

如果想针对listview内部的li刷新可以使用

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

否则报错误如下:

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

jquerymobile checkbox及时刷新才能获取其准确值

  1. 一般登录的时候 都有个记住用户名 记住密码 的两个checkbox 多选框
  2. 用jquerymobile 做页面 ,当勾选checkbox 时总是不能获取它正确的值。
  3. 解决办法:
  4. $('input[type="checkbox"]').bind('click',function() {
  5. $(this).prop('checked').checkboxradio("refresh");   // 绑定事件及时更新checkbox的checked值
  6. });
  7. 如果要用js去改变checkbox的值时也要及时刷新。
  8. $('input [type="checkbox"]').attr('checked',false).checkboxradio("refresh");
  9. $('input [type="checkbox"]').attr('checked',false).checkboxradio("refresh");
  10. 原因: 因为手动改变它的值后,jquerymobile不能重新渲染。 这样页面显示的值和实际值就不一样了。 (jquerymobile 把form表单元素都隐藏起来,然后用 js添加了一些元素易于美化input, select ,textarea 等元素的效果)
下拉框刷新
  1. $("#selectbox").html(optionList).selectmenu('refresh', true);
 
 
  1. 复选按钮
  2. $("input[type='checkbox']").attr("checked",true).checkboxradio("refresh");
  3. 单选按钮组:
  4. $("input[type='radio']").attr("checked",true).checkboxradio("refresh");
  5. 选择列表::
  6. var myselect = $("select#foo");
  7. myselect[0].selectedIndex = 3;
  8. myselect.selectmenu("refresh");
  9. 滑动条
  10. $("input[type=range]").val(60).slider("refresh");
  11. 开关 (they use slider):
  12. var myswitch = $("select#bar");
  13. myswitch[0].selectedIndex = 1;
  14. 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">

jquerymobile局部渲染的各种刷新的更多相关文章

  1. Jquery Mobile局部刷新后js和css失效,需局部渲染

    $(function () {    $("#submit").click(function(){      var storage = window.localStorage;  ...

  2. jqueryMobile 动态添加元素,展示刷新视图方法

    jqueryMobile动态添加元素jqueryMobile郏高阳 jQuery Mobile的是一个很好的移动开发框架,你可能已经知道,虽然它有很多难以解决的问题,但是我相信后续版本jquery会修 ...

  3. jquery刷新页面的实现代码(局部及全页面刷新)

    局部刷新: 这个方法就多了去了,常见的有以下几种: $.get方法,$.post方法,$.getJson方法,$.ajax方法如下 前两种使用方法基本上一样 下面介绍全页面刷新方法:有时候可能会用到  ...

  4. 【Jquery】jquery刷新页面(局部及全页面刷新)

    下面介绍全页面刷新方法:有时候可能会用到window.location.reload()刷新当前页面.parent.location.reload()刷新父亲对象(用于框架)opener.locati ...

  5. ajax结合mysql数据库和smarty实现局部数据状态的刷新

    效果状态:通过点击锁定状态实现状态锁定与不锁定之间的切换 1.主程序:01.php导入smarty和mysql类,取得数据导入列表模板 <?php    include './include/M ...

  6. problem:vue组件局部刷新,在组件销毁(destroyed)时取消刷新无效问题

    场景: 一个群发消息列表(数组) 列表下有多条消息(元素) 每条正在发送的消息数据状态需要实时刷新,发送完成时需要显示成功提示符合且不需要刷新,然后3秒消失.首次显示列表时,已经成功的状态不显示这个成 ...

  7. jquerymobile知识点:动态Grid的绑定以及刷新

    下面jquerymobile是ajax动态绑定和刷新的例子.直接上图以及代码. 下面是实例代码: //初始绑定 function GetInitBind(PageIndex, PageSize, sq ...

  8. AjaxAnyWhere 实现页面局部刷新,局部分页

    这个比較jquery.单纯ajax异步简单多了.不多说了直接上代码. 须要引入:ajaxanywhere-1.2.1.jar (最新)和 /ajaxAnyWhereDemo/WebRoot/js/aa ...

  9. $nextTick 页面局部刷新 延迟加载

    Vue中的nextTick涉及到Vue中DOM的异步更新,感觉很有意思,特意了解了一下.其中关于nextTick的源码涉及到不少知识,很多不太理解,暂且根据自己的一些感悟介绍下nextTick 本人写 ...

随机推荐

  1. 20171107--SQL变量,运算符,存储过程

    create database shujuku03 go use shujuku03 go create table jiaoshi--创建jiaoshi表-- ( code int primary ...

  2. 超炫酷web前端的jQuery/HTML5应用搜罗

    作为前端开发者,我们肯定都使用过非常多的jQuery插件,毋庸置疑,jQuery非常流行,尤其是结合HTML5和CSS3以后,让这些jQuery插件有了更多地动画效果,更为绚丽多彩. 1.HTML5/ ...

  3. LLVM language 参考手册(译)(6)

    模块级内联汇编(Module-Level Inline Assembly) 模块包含“module-level inline assembly”块,这与GCC中的“file scope inline ...

  4. 三角函数计算,Cordic 算法入门

    [-] 三角函数计算Cordic 算法入门 从二分查找法说起 减少乘法运算 消除乘法运算 三角函数计算,Cordic 算法入门 三角函数的计算是个复杂的主题,有计算机之前,人们通常通过查找三角函数表来 ...

  5. Centos(Linux) 根文件系统

    /下面的文件 /boot:系统启动相关的文件:如内核,inittrd ,以及MBR grub /dev :设备文件: 块设备:随机访问,数据块 如:USB 字符设备:线性访问,按字符为单位如:鼠标,按 ...

  6. Linux C 程序 信号及信号的处理(19)

    信号及信号的处理 1.Linux信号的介绍  信号是一种软件中断.Linux系统中根据POSIX标准扩展的信号机制.  1.信号来源      1.硬件方式           1.当用户按下某个键, ...

  7. Centos6.4版本下搭建LAMP环境

    Centos6.4版本下搭建LAMP环境 配置yum mkdir/mnt/cdrom mount/dev/cdrom  /mnt/cdrom 装载光盘 vi /etc/yum.repos.d/Cent ...

  8. String与StringBuffer对象问题

    下面的代码创建了三个String对象,其中pool中一个,heap中两个 String s1 = new String("abc"); String s2 = new String ...

  9. (转载)delphi文件流

    delphi文件流 [复制链接] 在Delphi中,所有流对象的基类为TStream类,其中定义了所有流的共同属性和方法. TStream类中定义的属性介绍如下: 1.Size: 此属性以字节返回流中 ...

  10. Android NDK环境配置

    之前做了一个基于ffmpeg的软解播放器,熟悉了NDK开发的配置环境过程,但是由于太忙一直没有时间写笔记. 首先,介绍一下在这里所参与协作的软件包: 1. JDK: 这个软件被Eclipse依赖. 2 ...