Layout resetting after 'back' button, hhen JS populates a list element

Layout resetting after 'back' button, hhen JS populates a list element

Hi there. Ive got a UL with ID ='listaTurmas'. All i want to do is, everytime this function is called, the list contents is refreshed according to the  Sessao.turmas array.

The first time it shows up, it works fine. The second time, layout is completely lost.
Would apreciate any help !

THis is my Div:

  1. <div data-role="page" id="turmas" data-theme="b">
  2. <div data-role="header">
  3. <h1>List</h1><a onClick="history.back(-1);" data-role="Button">Back</a>
  4. </div>
  5. <div data-role="content">
  6. <ul data-role="listview" id="listaTurmas" data-inset="true">
  7. <!-- javascript will fill this -->
  8. </ul>
  9. </div>

  10. <div data-role="footer">
  11. <h4>FOOTER</h4>
  12. </div>
  13. </div>

And this my code:
  1. function geraListaDeTurmas() {
  2. var countTurma = Sessao.turmas.length;
  3. $("#listaTurmas").empty();
  4. while(countTurma--) {
  5. var estaTurma = Sessao.turmas[countTurma];
  6. var estesAlunos = estaTurma.alunos;
  7. var countAluno = estesAlunos.length;
  8. var htmlMarcacao = "";
  9. $("#listaTurmas").append("<li class='listaTurma' class='listaTurma'><a onClick='selecionarTurma("+estaTurma.codigo+")'>  "+estaTurma.disciplina+" - Turma "+estaTurma.codigo+" - Serie - "+estaTurma.serie +" - Semestre "+ estaTurma.semestre+"</a></li>");

  10. }
  11. };