【发布时间】:2017-06-08 10:36:24
【问题描述】:
在我的 Meteor.JS 应用程序中,我想在从数据库中获取的元素上动态添加点击事件。不幸的是,单击后未触发功能(但将事件添加到 Template.algorithms.__eventsMap 属性)。我想知道我的方法是否正确以及可以纠正什么以触发该事件。
main.coffee:
Template.algorithms.onCreated ->
Template.instance().subscribe('algorithm-descriptions', {
onReady: () ->
for alg in AlgorithmDescriptions.find().fetch()
Template.algorithms.events({
"click .#{alg.button}": () ->
$(".#{alg.divClass}").scrollintoview({duration: 'slow'})
})
})
algorithms.jade:
.col-md-2
ul
each alg in algorithmDescriptions
li(class=alg.button)=alg.name
.col-md-10
each alg in algorithmDescriptions
div(class=alg.div)
h2=alg.name
【问题讨论】:
标签: javascript meteor coffeescript pug