When I generate my HTML using jquery the css doesn't load and leaves me an awful display.
Here is the code that generates the HTML :
function createHtml(type,idx,name,data)
{
switch(type)
{
case 'Temp + Humidity':
var data = data.split(", ");
$("#data").append('<li id="'+idx+'"><h2>' + name + ' :</h2><p style="color:coral;">' + data[0] + '</p><p style="color:lightblue;">' + data[1] + '</p></li>');
break;
case 'Wind':
var data = data.split(";");
$("#data").append('<li id="' + idx + '"><h2>' + name + ' :</h2><p>Direction :' + data[1] + ' Speed : ' + data[2] + '</p></li>');
break;
case 'Rain':
$("#data").append('<li id="' + idx + '"><h2>' + name + ' :</h2><p>' + data + 'ml</p></li>');
break;
case 'General':
$("#data").append('<li id="' + idx + '"><h2>' + name + ' :</h2><p>' + data + '</p></li>');
break;
case 'Thermostat':
$("#data").append('<li id="' + idx + '"><h2>' + name + ' :</h2><p>' + data + '°C</p><div class="ui-btn-right" data-role="controlgroup" data-type="horizontal"><a class="ui-btn ui-corner-all ui-icon-minus ui-btn-icon-notext" onclick="tempSetMinus(this.id)" id="' + idx + 'Minus">Minus Icon</a><a class="ui-btn ui-corner-all ui-icon-plus ui-btn-icon-notext" onclick="tempSetPlus(this.id)" id="' + idx + 'Plus">Plus Icon</a></div></li>');
break;
case 'Air Quality':
$("#data").append('<li id="' + idx + '"><h2>' + name + ' :</h2><p>' + data + '</p></li>');
break;
case 'Lux':
$("#data").append('<li id="' + idx + '"><h2>' + name + ' :</h2><p>' + data + '</p></li>');
break;
}
}
And here is what I get:
And what I want:


$( "#data" ).listview( "refresh" );api.jquerymobile.com/listview/#method-refresh