4

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");
});

2 Answers 2

4

Use collapsibleset() instead of listview("refresh"):

$("#data").collapsibleset();

See DEMO.

Sign up to request clarification or add additional context in comments.

1 Comment

Ah, I see. Try just collapsibleset(). I've updated my answer.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.