I have a JQueryMobile button inserted inside the ListView. When the button is hard-coded the css styling of the jquerymobile applies. But when I tried to insert a button programmatically the style was lost. How can I reapply the JQueryMobile's css to the button?
to give everyone any idea what I am talking about, this is my code to insert item on the ListView
//CODE TO ADD A JAVASCRIPT BUTTON TO THE LIST
var parent = document.getElementById("group-1");
var listItem;
listItem = document.createElement('li');
listItem.setAttribute('id',"group-1-row-0");
var inner= "<a href=\"#\" style=\"padding-top:0px;padding-left:0px;padding-bottom:0px\">";
inner = inner + "<div class=\"customTableLayout\">";
inner = inner + "<fieldset data-role=\"fieldcontain\" id=\"ui-softbutton\">";
inner = inner + "<input type=\"button\" id=\"ui-softbutton\" value=\"SOFTCODED\" />";
inner = inner + "</fieldset>";
inner = inner + "</div>";
inner = inner + "</a>";
listItem.innerHTML = inner;
parent.appendChild(listItem);
//WHEN YOU TRY TO ENABLE THIS CODE, THE DISPLAY BECOMES WEIRD
//$("#ui-softbutton").button();
//$("#ui-softbutton").button('refresh');
$(parent).listview("refresh");
to VIEW the result of this code and to see that the HARDCODED button works please see this JFiddle
Live Example:
Just needed to append the trigger('create') method
$(parent).listview("refresh").trigger('create');