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:
- <div data-role="page" id="turmas" data-theme="b">
-
- <div data-role="header">
- <h1>List</h1><a onClick="history.back(-1);" data-role="Button">Back</a>
- </div>
-
- <div data-role="content">
- <ul data-role="listview" id="listaTurmas" data-inset="true">
- <!-- javascript will fill this -->
- </ul>
- </div>
- <div data-role="footer">
- <h4>FOOTER</h4>
- </div>
- </div>
And this my code:
- function geraListaDeTurmas() {
- var countTurma = Sessao.turmas.length;
- $("#listaTurmas").empty();
- while(countTurma--) {
- var estaTurma = Sessao.turmas[countTurma];
- var estesAlunos = estaTurma.alunos;
- var countAluno = estesAlunos.length;
- var htmlMarcacao = "";
- $("#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>");
- }
- };