I have an empty list view:
<ul data-role="listview" data-theme="d" id="test">
</ul>
I'd like to add li tags which contain collapsible content dynamically, but I don't know how to "refresh" it so that the collapsible content shows up?
I tried:
$(document).on('pageinit', function() {
$('#test').append('<li><a href="#"><div data-role="collapsible" class="member-item" data-theme="a"><h3>title</h3><p>some content</p></div></a><a href="#">test</a></li>');
$('#test').listview("refresh");
});
But this only refreshes the li part.
Then I tried:
$(document).on('pageinit', function() {
$('#test').append('<li><a href="#"><div data-role="collapsible" class="member-item" data-theme="a"><h3>title</h3><p>some content</p></div></a><a href="#">test</a></li>');
$('#test').listview("refresh");
$('.member-item').collapsible('refresh');
});
But then I just get the loading icon and the page does not load?
Looks like I had to trigger "create" then refresh the listview:
$('#test').trigger('create');
$('#test').listview("refresh");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.