JQuery Mobile, creating a complex set dynamically through ajax, does not apply style

Possible duplicate:
Dynamically add folding elements

I dynamically create an assembly and add it to the page with $('#myID').html(htmlcode). The style does not apply to the page. How can I get jquery mobile to apply its style?

(I use $.get()to request a web service. The content that is returned, I scroll to create markup)

+5
source share
4 answers

This works for me. My ajax returns a bunch of h3, which I insert in the collapsible div and add the p tag for the content.

$(document).ready(function(){

    $.get(my_url, function(data) {
        var content = $('div[data-role="content"]').html(data);
        $('h3').each(function(h3_element) {
            var coll = $('<div class="ui-collapsible-contain" name="blog"  data-role="collapsible" data-collapsed="true">');
            coll.append($(this));
            coll.append($('<p>'));
            content.append(coll);
        });
        content.trigger( "create" );        
    });

});
+5
source
$content.find(":jqmData(role=collapsible)").collapsible();
+1
source

All Articles