【发布时间】:2017-09-26 13:21:27
【问题描述】:
使用 Meteor,我得到了一个模板,其中包含 2 个其他模板 A 和 B。
A 有一个<select> 标签,B 有一个<canvas>,根据模板 A 的选择,将在其上绘制一些东西。
When the selection changes, A should call someMethod` of B, and this method should get some data from the db and then draw the canvas.我怎样才能实现这种行为?
简单地使用Template.B.someMethod = function (bla) ...,然后在A 的JS 中调用Template.B.someMethod(hi) 会导致错误,因为someMethod 访问B 的DOM canvas 元素,当A 在加载时第一次更改时该元素不会呈现。
调用该方法的合适方式是什么?还是应该将这两个模板合并在一起?
【问题讨论】: