JQuery Mobile changing checkbox state and calling checkboxradio('refresh') properly
===

I've read many posts on this site about how to work with checkboxes in JQM 1.1.1, but none of the solutions have worked for my situation. I have the following container

     <div id="updates_list" data-role="collapsible-set"></div>

to which I am adding items like the following dynamically:

     <div data-role="collapsible" class="update_item">
         <h3><input type="checkbox" id="cb_XXX" class="update_cb" checked="checked">ItemX</h3>
         <p>Description</p>
     </div>

The collapsible data-role tags don't matter. Removing them does nothing to solve my problem. When I run the code that inserts some items, it looks like this:

![enter image description here][1].

This is what I want. Adding a <label> tag causes JQM to style the checkbox as a nested item on the collapsible list, which I do not want. My much reduced checkbox handler contains:

     event.stopPropagation();
     if ($(this).is(':checked')){
        This.attr('checked', 'checked').checkboxradio('refresh');
     } else {
        This.removeAttr('checked').checkboxradio('refresh');
     }
     return false;

but the call checkboxradio('refresh'), though required for this to work, throws "cannot call methods on checkboxradio prior to initialization" exception. Catching the exception breaks the toggling of the checkbox state. Trying to do this with the $.prop() didn't work.

So, in trying to initialize things, calling

     $(selector).trigger('create');

before .checkboxradio() with any selector, such as '#updates_list' or '.update_cb' gets rid of the exception, but also breaks the toggling of the checkbox. Not only that, but the trigger('create') call also destroys the layout:

![enter image description here][2]

I tried doing all of this with straight Javascript with onclick attribures, but not only could I not get the toggling to work, but clicking on the checkbox would also open and close the collapsible item no matter what I returned.

So could someone enlighten me on the *right* way to do this, please? Toggling the checkbox at the end of the handler and letting the exception fly (I'm done anyway) is so *wrong*.




  [1]: http://i.stack.imgur.com/Xgjov.png
  [2]: http://i.stack.imgur.com/cvU0d.png