jQuery Mobile的通过AJAX不适造型动态创建可折叠集不适、造型、可折叠、动态

2023-09-10 17:24:06 作者:b1е理我╮

可能重复:   Dynamically加入

我动态创建一个可折叠组,并使用 $('#身份识别码),将其添加到网页的HTML(HTML code)。造型没有被应用到页面。我怎样才能jQuery Mobile的应用它的造型?

I am dynamically creating a Collapsible set and adding it to the page using $('#myID').html(htmlcode). The styling is not being applied to the page. How can I get jQUery mobile to apply it styling?

(我用 $。获得()来查询该回来我遍历创建标记网页内容的服务。)

(I am using $.get() to query a web service.The content that returned I am looping through to create the markup)

推荐答案

这是为我工作。我的AJAX返回一大堆,我插入一个可折叠的股利和追加AP标签内容H3的。

This is working for me. My ajax returns a bunch of h3's which I insert into a collapsible div and append a p tag for the content.

$(document).ready(function(){

    $.get(my_url, function(data) {
        var content = $('div[data-role="content"]').html(data);
        $('h3').each(function(h3_element) {
            var coll = $('<div class="ui-collapsible-contain" name="blog"  data-role="collapsible" data-collapsed="true">');
            coll.append($(this));
            coll.append($('<p>'));
            content.append(coll);
        });
        content.trigger( "create" );        
    });

});
 
精彩推荐
图片推荐