开发者

jQuery Mobile - How to mobile-ize a checkbox rendered via jQuery Templates

开发者 https://www.devze.com 2023-04-12 01:36 出处:网络
On a jQuery Mobile site I have elements of a <ul> being populated by jQuery Templates, filling out <li> items so something like this:

On a jQuery Mobile site I have elements of a <ul> being populated by jQuery Templates, filling out <li> items so something like this:

<ul>
</ul>
<button>Fill</button>

<script type="text/x-jquery-tmpl" id="tmpl-items">
<li><input type="checkbox" name="guys" /> ${FirstName} ${Las开发者_如何学JAVAtName}</li>
</script>

<script type="text/javascipt">
$('this-page-id').live('pageinit', function() {
  $('button').click(function() {
    $('#tmpl-items').tmpl(MyApp.Model)
      .appendTo('ul')
  });
})
</script>

Everything works, except the checkbox renders as a normal checkbox, not a cool jquery-mobilized checkbox. I know that the trick is to call "refresh" on the widget but I have no idea what widget I should be using - there is no data-role here. Does anybody know?


Can you triggering a create on the ul,like this $('ul').trigger('create');

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号