Clearling a List with jQuery Mobile - layout issue

Clearling a List with jQuery Mobile - layout issue

Hello there.

I got the simple following function that will populate a DIV element with a list

  1. function populate() {
  2. var turma = Persistencia.getTurma();
  3. var ct = turma.alunos.length;
  4. $("#listaAlunosChamados").remove(); //removes the UL if exists (i tested w/o it)
  5. $('#alunosChamados').html('<ul data-role="listview" id="listaAlunosChamados" class="listaAlunosChamados" data-inset="true">'); // creates the UL into the DIV #alunosChamados
  6. while(ct--) { // fills the list
  7. var aluno = turma.alunos[ct];
  8. if(aluno.presente) {
  9. $("#listaAlunosChamados").append("<li id='alunoChamado' class='alunoChamado'><img src='img/ok.gif' class='ui-li-icon'/>"+aluno.nome+"</li>");
  10. } else {
  11. $("#listaAlunosChamados").append("<li id='alunoChamado' class='alunoChamado'><img src='img/x.gif' class='ui-li-icon'/>"+aluno.nome+"</li>");
  12. }
  13. }
  14. $('#alunosChamados').append("</ul>"); // close the list
  15. window.location = "app.html#chamadaFeita";
  16. };

The first time i run this, it goes nicely. After that, the layout gets really buggy, and its displayng like a common list not like an jQuery Mobile list. Does anyone what can be happening ?

Thanks alot for the attention !