1

I am trying to include a collapsible widget in jquery mobile. The content is dynamic so I am using a markup to do this, but just for illustration I have included default text. The following code just brings no widget but just the text appears, the styling of the widget doesn't appear. Here is my javascript

  description_markup += '<h4>Description heading</h4><p>'+description+'</p>'; 

   $('#Desc').empty().append(description_markup);

HTML

 <div data-role="content" class= "ui-content" data-theme="d">
       <p id="message"/>
       <div id ="videoDisplay"></div>
       <div id ="vidLikeDislikebutton"></div>
        <div id ="Desc" data-role="collapsible"
             data-theme="b" data-content-theme="b"
             class="ui-collapsible ui-collapsible-inset
                    ui-collapsible-themed-content">
       </div>
</div><!-- /content -->

when I put the Desc div outside the content div, the text appears with a black background.

Please help

4

1 回答 1

3

jQuery Mobile 团队仍在努力创建可折叠的方法,例如refresh. 不幸的是,collapsible 现在不接受任何方法。因此,用新的折叠式替换当前的折叠式是唯一的方法。

演示

var description_markup = '<div data-role="collapsible" id="Desc" data-theme="e" data-content-theme="b"><h3>Description heading</h3><p>collapsible</p></div>';
$('#Desc').replaceWith(description_markup);
$('#Desc').collapsible();

如果可折叠功能得到了增强并且您不想替换它,您仍然可以进行修改。

$('#Desc .ui-btn-text').text('new header');
$('#Desc .ui-collapsible-content').append('<p>new content</p>');

在可折叠组件中插入小部件需要.trigger('create')增强小部件标记

$('#Desc .ui-collapsible-content').append('<ul data-role="listview"><li><a>link</a></li><li><a>link</a></li></ul>').trigger('create');
于 2013-07-16T00:07:54.707 回答