Good afternoon.
I'm making a mobile application with jquery mobile and I have a problem with the collapsible elements.
I make an ajax call to the server to get data, and if the answer is correct, what I want is to insert as many collapsible elements as responses from the server.
HTML code:
<div data-role="page" id="paginaListado">
<div data-role="header">
<h1>Listado</h1>
</div>
<div data-role="content">
<div id="seccionListadoMaterial"></div>
</div>
</div>
Javascript code:
$("#seccionListadoMaterial").html("");
$.ajax({
type: "POST",
url: "php/listadoMaterial.php",
cache: false,
success: function(data){
for(var i = 0 ; i < 4 ; i++){
$("#seccionListado").append("<div data-role='collapsible'><h3>Esto es lo de fuera</h3><p>Y esto lo de dentro</p></div>");
}
}
});
$.mobile.changePage('#paginaListado');
If I do it as shown above, it looks like this:
On the other hand, if instead of doing the for inside the aces of ajax I do it out, it looks ok:
I need to do it within the ajax call to be able to put the collapsible text that I receive from the server.
I have tried to change the subject, but nothing, I have also tried to do it "collapsible-set" but the same.
Why can it be happening?
Greetings.