【发布时间】:2015-03-31 08:34:37
【问题描述】:
我对@987654321@ 的工作方式感到困惑。查看以下代码:
home.html
<template name="homePage">
<section id="home-page">
<div class="container">
<h1>Thought of the day:</h1>
<div id="totd">
<span>{{thought}}</span>
</div>
</div>
</section>
</template>
home.coffee
timer = 0
Template.homePage.rendered = ->
this.find('#totd')._uihooks =
insertElement: (node, next) ->
console.log 'Inserted'
removeElement: (node) ->
console.log 'Removed'
Session.set 'randThought', Random.choice thoughts
timer = Meteor.setInterval shuffleThoughts, 5000
Template.homePage.destroyed = ->
Meteor.clearInterval timer
thoughts = [
"My socks smell like sausages."
"I sure wish I had a bag of crisps right about now."
"I need more thoughts."
]
Template.homePage.helpers
thought: -> Session.get 'randThought'
shuffleThoughts = ->
Session.set 'randThought', Random.choice thoughts
我希望随机的想法能够很好地淡出/淡入。但我从来没有看到控制台中出现任何东西,所以显然它不起作用。究竟是什么触发了_uihooks?我做错了什么?
【问题讨论】:
-
查看这篇文章,了解webtempest.com/meteorjs-animation
标签: meteor meteor-blaze