javascript - Refresh after adding DIV dynamically using jQuery Mobile - Stack Overflow

I'm trying to add a div dynamically using jQuery mobile, but after adding it, the CSS is not appli

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

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");
});
Share Improve this question edited Mar 14, 2013 at 20:48 Mils asked Mar 14, 2013 at 20:33 MilsMils 1,5083 gold badges19 silver badges44 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

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

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

See DEMO.

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742385636a4434001.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信