jquery mobile界面数据刷新

JQM里面当我们更新了某些页面标签(如: listview, radiobuttons, checkboxes, select menus)里的数据时,必须做refresh操作.

为什么必须做refresh操作操作呢?因为JQM在做页面渲染的时候,为了使样式跟客户端程序相似, 隐藏了原始的标签然后用一些新的标签和自定义的样式来表现原标签,其实新样式的标签已经不是原来的标签,所以更新了数据必须做refresh操作.

各类标签的刷新

1.Textarea fields

[html]   view plain copy
  1. $('body').prepend('<textarea id="myTextArea"></textarea>');  
  2. $('#myTextArea').textinput();  

2.Text input fields
[html]   view plain copy
  1. $('body').prepend('<input type="text" id="myTextField" />');  
  2. $('#myTextField').textinput();  

3.Buttons
[html]   view plain copy
  1. $('body').append('<a href="" data-theme="e" id="myNewButton">testing</a>');  
  2. $('#myNewButton').button();  

4.Combobox or select dropdowns
[html]   view plain copy
  1. <label for="sCountry">Country:</label>  
  2. <select name="sCountry" id="sCountry">  
  3. <option value="">Where You Live:</option>  
  4. <option value="ad">Andorra</option>  
  5. <option value="ae">United Arab Emirates</option>  
  6. </select>  
  7.     
  8. var myselect = $("#sCountry");  
  9. myselect[0].selectedIndex = 3;  
  10. myselect.selectmenu('refresh');  

5.Listviews
[html]   view plain copy
  1. <ul id="myList" data-role="listview" data-inset="true">  
  2. <li>Acura</li>  
  3. <li>Audi</li>  
  4. <li>BMW</li>  
  5. </ul>  
  6.     
  7. $('#mylist').listview('refresh');  

6.Slider control
[html]   view plain copy
  1. <div data-role="fieldcontain">  
  2. <label for="slider-2">Input slider:</label>  
  3. <input type="range" id="slider-2" value="25" min="0" max="100" />  
  4. </div>  
  5.     
  6. $('#slider-2').val(80).slider('refresh');  

7.Toggle switch
[html]   view plain copy
  1. <div data-role="fieldcontain">  
  2. <label for="toggle">Flip switch:</label>  
  3. <select name="toggle" id="toggle" data-role="slider">  
  4. <option value="off">Off</option>  
  5. <option value="on">On</option>  
  6. </select>  
  7. </div>  
  8.     
  9. var myswitch = $("#toggle");  
  10. myswitch[0].selectedIndex = 1;  
  11. myswitch .slider("refresh");  

8.Radio buttons
[html]   view plain copy
  1. <div data-role="fieldcontain">  
  2.     <fieldset data-role="controlgroup" data-type="horizontal">  
  3.       <legend>Layout view:</legend>  
  4.           <input type="radio" name="radio-view" value="list" />  
  5.           <label for="radio-view-a">List</label>  
  6.           <input type="radio" name="radio-view" value="grid" />  
  7.           <label for="radio-view-b">Grid</label>  
  8.           <input type="radio" name="radio-view" value="gallery" />  
  9.           <label for="radio-view-c">Gallery</label>  
  10.     </fieldset>  
  11. </div>  
  12.     
  13. $("input[value=grid]").attr('checked',true).checkboxradio('refresh');  


9.Checkboxes

[html]   view plain copy
  1. <div data-role="fieldcontain">  
  2. <fieldset data-role="controlgroup">  
  3. <legend>Agree to the terms:</legend>  
  4. <input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" />  
  5. <label for="checkbox-1">I agree</label>  
  6. </fieldset>  
  7. </div>  
  8.     
  9. $('#checkbox-1').attr('checked',true).checkboxradio('refresh');  

10.controlgroup

controlgroup动态加载 出现错误  cannot call methods on checkboxradio prior to initialization; attempted to call method 'refresh'

需要加入以下代码

[javascript]   view plain copy
  1. $.mobile.pageContainer.trigger("create");  
  2. $("#voteGroup").controlgroup("refresh");  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值