Naveed Qamar
Naveed Qamar

Reputation: 127

Jquery Mobile Dynamic collapsible contents are not taking any style

I am trying to create the dynamic collapsible divs using jquery mobile but the generated div are not taking any styles.

Can anybody solve this issue. :)

        jQuery.get('../config/la/english.txt', function(data) {

            for (var i = 0; i < data.length; i++) {
                //alert(data[i]);
                $('<div data-role="collapsible" data-collapsed="true" data-theme="c" data-content-theme="d" id="'+data[i]+'"><h3>'+ data[i] +'</h3></div>').appendTo("div#main");
            }
        }); 

Upvotes: 1

Views: 1508

Answers (3)

AJ J
AJ J

Reputation: 539

You have to call the collapsible() method after you finish the Loop in which you are creating the div elements.

Use the container DIV (which contains all the collapsible div elements you created) to call the collapsible() like so :

$('#container').find('div[data-role=collapsible]').collapsible();

Upvotes: 0

Khasha
Khasha

Reputation: 1669

$("Selector").find('div[data-role=collapsible]').collapsible();

Upvotes: 2

MartijnvdB
MartijnvdB

Reputation: 1002

you could try adding

$(data[i]).collapsible({refresh:true});

in the for-loop, after appending the div to your <div#main>

Upvotes: 0

Related Questions