I'm trying to add a div dynamically using jQuery mobile, but after adding it, the CSS is not applied even with the refresh.
The is the example.
Code :
$(function() {
$("#data").append('<div data-role="collapsible"><h3>Div2</h3><p>Content Div2...</p></div>');
$("#data").listview("refresh");
});
I'm trying to add a div dynamically using jQuery mobile, but after adding it, the CSS is not applied even with the refresh.
The is the example.
Code :
$(function() {
$("#data").append('<div data-role="collapsible"><h3>Div2</h3><p>Content Div2...</p></div>');
$("#data").listview("refresh");
});
Share
Improve this question
edited Mar 14, 2013 at 20:48
Mils
asked Mar 14, 2013 at 20:33
MilsMils
1,5083 gold badges19 silver badges44 bronze badges
2 Answers
Reset to default 4Use collapsibleset()
instead of listview("refresh")
:
$("#data").collapsibleset();
See DEMO.
I"m use such method
try{
$("#data").listview("refresh");
}catch{
$("#data").listview();
}finally{
$('[data-role=collapsible]').collapsible();
}
This problem occurs when an item is added to the dynamic