jQuery Mobile的通过AJAX不适造型动态创建可折叠集 [英] jQuery Mobile creating a Collapsible set dynamically via ajax does not apply styling

查看:170
本文介绍了jQuery Mobile的通过AJAX不适造型动态创建可折叠集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/4214538/dynamically-adding-collapsible-elements">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" );        
    });

});

这篇关于jQuery Mobile的通过AJAX不适造型动态创建可折叠集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆