简体   繁体   English

动态内容更改后,jQM 1.4.2可折叠集无法正确刷新

[英]jQM 1.4.2 Collapsible set not refreshing properly after dynamic content change

I know this question has been asked before and I've read all the solutions. 我知道之前曾有人问过这个问题,我已经阅读了所有解决方案。 None of them work. 他们都不工作。

I have a collapsible set with 5 collapsible elements in it. 我有一个带有5个可折叠元素的可折叠套件。

<div data-role="collapsibleset" id="mySet" data-inset="false" class="ui-nodisc-icon ui-alt-icon">
  <div data-role="collapsible" id="1">
  </div>
  <div data-role="collapsible" id="2">
  </div>
  <div data-role="collapsible" id="3" >
  </div>
  <div data-role="collapsible" id="4">
  </div>
  <div data-role="collapsible" id="5">
  </div>
</div>

The components are built with jQuery and each one has its html updated with. 这些组件是使用jQuery构建的,每个组件的html均已更新。

$('#' + key).html(myHTMLString);

Where the key is the id of the div and the myHTMLString is constructed in jQuery. 其中的键是div的ID,而myHTMLString是在jQuery中构造的。

This works perfectly the first time you go to the page but after that the collapsible set loses all formating. 第一次访问该页面时,此方法非常有效,但此后可折叠集将丢失所有格式。 There are no anchors around the collapsible headings and no div with a class="ui-collapsible-content ui-body-inherit" as you get on the first time you visit. 第一次访问时,可折叠标题周围没有锚点,并且类=“ ui-collapsible-content ui-body-inherit”的div也没有。

I've tried every combination of 我尝试了各种组合

$('#mySet').collapsibleset().trigger('create');
$("#mySet").collapsibleset("refresh");
$( "#mySet" ).trigger( "updatelayout" );
$("#mySet").enhanceWithin();

and more that I can find. 还有更多我能找到的。 Nothing changes it. 没什么改变。

Any ideas why? 有什么想法吗? I'd be far less baffled if it didn't work at all but being fine on the first visit but not the next? 如果它根本不起作用,但第一次访问时没问题,那么我就不会感到困惑。 Bizarre. 离奇。

EDIT: 编辑:

I've altered the code so the h4 and p tags are in the html document instead of being dynamically inserted, and I'm adding the data to them like this: 我已经更改了代码,因此h4和p标签位于html文档中,而不是被动态插入,并且我将数据添加到它们中是这样的:

 $('#' + key + "_head").html(myHeadingHTMLString);
 $('#' + key + "_content").html(myContentHTMLString);

This has restored the collapsible div but it has still taken away the formatting, because on the second visit (it still works fine the first time) the anchor tag with 这已经恢复了可折叠的div,但仍然取消了格式设置,因为在第二次访问(第一次仍然可以正常工作)时,带有

<a href="#" class="ui-collapsible-heading-toggle ui-btn ui-btn-icon-left ui-icon-plus ui-btn-inherit"> 

is not added on the second visit. 在第二次访问时未添加。

Why on Earth not? 为什么在地球上不行? I'm using .collapsibleset() at the end of constructing it all and its the same whatever I do. 我在构造所有内容时都使用了.collapsibleset(),无论我做什么,都一样。

尝试:

$("#mySet").enhanceWithin().collapsibleset('refresh');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM