爲什麼模板會呈現與我的模板中的每個模板相關的次數。Template #each&rendering
<template name="carousel">
<div class="pikachoose">
<ul class="carousel" >
{{#each article}}
<li><a href="#"><img src="{{image}}" width="500" height="250" alt="picture"/></a><span>{{caption}}</span></li>
{{/each}}
</ul>
</div>
</template>
Template.carousel.article = function() {
return News.find({},{limit: 3});
}
Template.carousel.rendered = function() {
//$(".pika-stage").remove();
alert($(".carousel").html());
//$(".carousel").PikaChoose({animationFinished: updateNewsPreview});
}
在這種情況下,它會提醒3次。
' 。'rendered'不是問題的原因,而是一個指標。這個問題是反應性的副作用。此外,使用超時等待數據被提取是一個**糟糕的主意。 –
你說得很好,先生。 –