【发布时间】:2015-05-31 04:36:54
【问题描述】:
我想将 Turn.js 集成到一个流星项目中,但是遇到了一个“小”问题,
脚本在我第一次“加载”模板时运行良好,但当我遇到相同的模板时就无法运行。
{{#if correspondances_readingMode}}
<script >
function loadApp() {
// Create the flipbook
$('.flipbook').turn({
// Width
width:922,
// Height
height:600,
// Elevation
elevation: 50,
// Enable gradients
gradients: true,
// Auto center this flipbook
autoCenter: true
});
}
// Load the HTML4 version if there's not CSS transform
yepnope({
test : Modernizr.csstransforms,
yep: ['../../lib/turn.js'],
nope: ['../../lib/turn.html4.min.js'],
both: ['css/basic.css'],
complete: loadApp
});
</script>
<style>
.page{
width:400px;
height:300px;
background-color:white;
line-height:300px;
font-size:20px;
text-align:center;
}
</style>
<div class="flipbook">
{{#each myPost}}
<div class="page">
{{{text}}}
</div>
{{/each}}
</div>
{{/if}}
似乎脚本仅在用户第一次遇到模板时才执行,但第二次不会再次启动。
我尝试了很多东西,但我开始认为这是因为车把 {{#if}}
附注: 在 chrome 上第二次加载它时,它不会将 turn.js 显示为脚本:
【问题讨论】:
-
尝试使用模板渲染处理程序docs.meteor.com/#/full/template_onRendered
-
似乎我无法完成这项工作,即使我创建了另一个在 'correspondances_readingMode' 时调用的模板(因此移除车把并拥有一个唯一的模板,onRendered 不起作用,甚至没有一次)
标签: meteor spacebars meteor-helper turnjs