I have a little fiddle that I modified to demonstrate the problem I'm currently having http://jsfiddle.net/TPxT7/. Basically I need the textboxes
to have the nice jQuery Mobile
style, but regardless of what I refresh
or trigger
nothing seems to change. The collapsibles are always going to be created dynamically.
I'll attach the codes in-case there is something wrong with the links:
HTML:
<div id="medListDiv" data-role="collapsible-set" data-theme="e" data-content-theme="e" style="padding:10px;">
</div>
SCRIPT (Sorry about lack of indentation):
$(function() {
var key, value;
var Storage = 5
// loop through local storage
for (var i = 0; i < Storage; i++) {
// retrieve the key
key = i;
// set the field from the key
value = "Medicine" + i.toString();
//$("#medListDiv").show();
var text = '<div data-role="collapsible" data-collapsed="true" data-iconpos="right">' + '<h2>' + value + '</h2>' + '<input type="text" placeholder="Quantity" />' + '<textarea cols="40" rows="4" placeholder="Type any directions written on your prescription for the above medicine." ></textarea></div>';
$("#medListDiv").append(text);
}
$('#medListDiv').find('div[data-role=collapsible]').collapsible();
//$('.ui-collapsible-set').collapsible("refresh");
//$("#medListDiv").trigger("create");
//$('.ui-collapsible-set').trigger("create");
});
As you can see at the bottom I have tried adding the following bits of codes (not all at once):
$('.ui-collapsible-set').collapsible("refresh");
$("#medListDiv").trigger("create");
$('.ui-collapsible-set').trigger("create");
and I have also tried to follow some of the answers give on This question but nothing seems to make any difference, maybe I'm missing something, but I can't seem to work my head around it.
To makes things more clear, I want it too look like this Fiddle I created in static mode.
Any suggestions or ideas will be greatly appreciated.
After a silly thought and a quick look around other questions and answers I solved it by just adding the following:
$('#medListDiv').find('div[data-role=collapsible]').collapsible();
$('#medListDiv').collapsibleset("refresh"); //This did the trick
$('#medListDiv').trigger("create");
Thank you for reading/passing by :)