George Mauer
George Mauer

Reputation: 122202

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

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} ${LastName}</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?

Upvotes: 0

Views: 277

Answers (1)

user700284
user700284

Reputation: 13620

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

Upvotes: 1

Related Questions