jQM 1.4.2动态内容更改后,可折叠集不正确刷新 [英] jQM 1.4.2 Collapsible set not refreshing properly after dynamic content change

查看:335
本文介绍了jQM 1.4.2动态内容更改后,可折叠集不正确刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题之前已被问过,我已经阅读所有的解决方案。它们都不工作。

I know this question has been asked before and I've read all the solutions. None of them work.

我有一个可折叠的集合,其中包含5个可折叠元素。

I have a collapsible set with 5 collapsible elements in it.

<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>

这些组件是用jQuery构建的,每一个都用它的html更新。

The components are built with jQuery and each one has its html updated with.

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

其中键是div的id,myHTMLString是在jQuery中构造的。

Where the key is the id of the div and the myHTMLString is constructed in jQuery.

这是完美的第一次你去的页面,但之后,可折叠集失去所有形成。在第一次访问时,没有可折叠标题周围的锚点和没有类=ui-collapsible-content ui-body-inherit的div。

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.

我尝试了每个组合

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

没有任何改变。

任何想法为什么?如果它不工作,但是在第一次访问,但不是下一个罚款,我会很少的困惑。 bizarre。

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.

编辑:

我修改了代码,h4和p标签都在html文档,而不是动态插入,我将数据添加到他们像这样:

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:

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

这恢复了可折叠的div,但它仍然带走了格式,因为在第二次访问它仍然工作正常第一次)锚标签与

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

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

为什么在地球上不是?

Why on Earth not? I'm using .collapsibleset() at the end of constructing it all and its the same whatever I do.

推荐答案

尝试:。我们在构建它的时候使用.collapsibleset

Try:

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

这篇关于jQM 1.4.2动态内容更改后,可折叠集不正确刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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