1

I cannot for the life of me get Jquery mobile to properly refresh a control group after appending to it dynamically. I have tried .controlgroup('refresh', true); .trigger('pagecreate'); and everything else I have found on here.

Please view my jsfiddle demo of the problem. If you add a radio button it does not format properly in jquery mobile.

The difference between this and Dynamic controlgroup and checkboxes unstyled is that mine appends to the control group after an action takes place not when the page is loaded.

http://jsfiddle.net/msenmyud/7/

$( "#addCard" ).click(function() {
    $('<input name="card1" value="ground" type="radio" class="creditCardChoice" id="card4"><label for="card3">Visa Ending in 3333</label>')
    .appendTo("#CCSelection");

    $("input[type='radio']").checkboxradio();
    $('input:radio').checkboxradio('refresh');
    $("[data-role=controlgroup]").enhanceWithin().controlgroup("refresh");
    $('#CCSelection').controlgroup('refresh', true);
    $("#CCSelectionForm").trigger('create');
    $("#saved-credit-cards-page").trigger('pagecreate'); 
}); 
Community
  • 1
  • 1
  • what is this function `controlgroup` ? never heard of it. The code is a complete mess, like a bomb **exploded** and this is the remains of it. – vsync Oct 07 '15 at 23:58
  • the answer is [here](http://stackoverflow.com/questions/5663033/dynamic-controlgroup-and-checkboxes-unstyled/20692597#20692597). Also, make sure you dont add duplicate ID's `card3` etc. – Omar Oct 08 '15 at 08:49
  • That is not the answer, it is a different question and does not work when doing that still. That only works if you are appending it on the initial page load not after the fact. – Anthony Allard Oct 12 '15 at 21:35

0 Answers0