【发布时间】:2015-06-18 06:52:05
【问题描述】:
我正在尝试执行对外部程序的调用,以在 JQuery Mobile 的可折叠项内的 DIV 中创建内容,以便在打开可折叠项时出现 JQM 可折叠项中的 div 时运行一些代码。我正在尝试使用 jquery.appear 插件 (https://github.com/morr/jquery.appear),如下所示:
<div id="coll2" data-role="collapsible" data-mini="true" data-inset="false" data-iconpos="right">
<h1>Collapsible 1</h1>
Collapsible Title!
<div id="2wrapper"></div>
</div>
<script type="text/javascript">
$(document.body).on('appear', '#2wrapper', function() {
// this element is now inside browser viewport
alert("Script running");
$("#2wrapper").load('some-external-program-content.cgi');
});
</script>
我显然遗漏了一些东西,因为当可折叠打开时 div 没有更新。在这种情况下会出现工作吗?或者有没有更有效的方法来实现这种“按需”加载可折叠内容的方式?
【问题讨论】:
标签: html jquery-mobile external jquery-mobile-collapsible