dynamic jquery radio buttons using.html() not rendering.

dynamic jquery radio buttons using.html() not rendering.

I am trying to make some dynamic jquery mobile radio buttons by rewriting a div's html. My app retrieves data every few days into a txt file that is stored on the phone. Is uses this text information to rewrite the number of radio buttons that are choices for props to use in the game.

The code written by the function below works fine when the output is pasted in manually and the page is restarted, but when I run the function from the click in the first radio button it renders as standard html with no styles. Is it possible to just replace html and have it render in jquery style?

  1. <div id=propchoices>    
  2. <fieldset data-role='controlgroup' id=field>
  3. <legend>Choose where to place the prop:</legend>
  4. <input type='radio' name='radio-choice' id='radio-choice-0' value='choice-0' checked='checked' />
  5. <label for='radio-choice-0' onClick=displayProps() >head</label>
  6. <input type='radio' name='radio-choice' id='radio-choice-1' value='choice-1' checked='checked' />
  7. <label for='radio-choice-1'>arm</label>
  8. <input type='radio' name='radio-choice' id='radio-choice-2' value='choice-2' checked='checked' />
  9. <label for='radio-choice-2'>foot</label>
  10. </fieldset>
  11. </div>

  12. <script>
  13. var propchoicesA=new Array("head","arm","foot");

  14. function displayProps(){

  15.     data="<fieldset data-role='controlgroup'>"
  16.     data+="<legend>Choose a pet:</legend>"

  17.     for(i=0;i<propchoicesA.length;i++){
  18.              data+="<input type='radio' name='radio-choice' id='radio-choice-"+i+"' value='choice-"+i+"' checked='checked' />";
  19.          data+="<label for='radio-choice-"+i+"'>"+propchoicesA[i]+"</label>";
  20.         
  21.         
  22.     }
  23.     data+="</fieldset>";
  24.     alert(data);
  25.     if($(document).ready){
  26.         alert("yo");

  27.     $("#propchoices").html(data);
  28.     }
  29. }

  30. </script>