15
votes

I'd like to apply autogenerated jQuery Mobile style (classes jQuery Mobile applies on page loading) after additionnal content loading via Ajax.

I load some content via Ajax which is parsed and organised into a <ul>, but the style jQuery usually applies on page loading isn't applied again on the Ajax loaded content.

2
FYI: On listview the refresh 'method' explained by Cyril is working fine. If you are using elements which don't support 'refresh', you can use the new trigger function from 1.0b3: $('#my_element_id').trigger('create'); - Smamatti

2 Answers

14
votes

Assuming your ul is a jquery-mobile "listview", try to refresh the entire list by using :

$('#yourlist').listview('refresh');

jQuery Mobile doucmentation http://jquerymobile.com/demos/1.0a2/#docs/forms/plugin-eventsmethods.html

2
votes

I was having troubles with this refresh method as well, got it working after a bit more searching by removing 'refresh', ie :

$('#yourlist').listview();

Found with explanation at http://forum.jquery.com/topic/wish-listview-refresh-would-go-away. Works ok in 1.1.1