【问题标题】:Refresh after adding DIV dynamically using jQuery Mobile使用 jQuery Mobile 动态添加 DIV 后刷新
【发布时间】:2013-03-15 13:56:02
【问题描述】:

我正在尝试使用 jQuery mobile 动态添加 div,但添加后,即使使用 refresh 也不会应用 CSS。

example

代码:

$(function() {
     $("#data").append('<div data-role="collapsible"><h3>Div2</h3><p>Content Div2...</p></div>');
     $("#data").listview("refresh");
});

【问题讨论】:

    标签: javascript jquery html css jquery-mobile


    【解决方案1】:

    使用collapsibleset() 代替listview("refresh")

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

    DEMO

    【讨论】:

    • 啊,我明白了。试试collapsibleset()。我已经更新了我的答案。
    【解决方案2】:

    我用这种方法

    try{
        $("#data").listview("refresh");
    }catch{
        $("#data").listview();
    }finally{
        $('[data-role=collapsible]').collapsible();
    }
    

    当一个项目被添加到动态时会出现这个问题

    【讨论】:

      猜你喜欢
      • 2012-05-20
      • 2012-04-20
      • 2012-03-26
      • 1970-01-01
      • 2013-01-08
      • 2012-03-09
      • 1970-01-01
      • 2012-07-19
      • 2013-12-06
      相关资源
      最近更新 更多