最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论