2015-06-28 21 views

回答

1

我能想到的唯一更干燥的解决方案是放弃coolLogic左右的匿名函数。

Template.cardA.onRendered(coolLogic); 
Template.cardB.onRendered(coolLogic); 
1

模板是一个对象,这样你就可以遍历其成员:

_.each(["cardA", "cardB"], function(t) { 
    Template[t].onRendered(function() { 
    coolLogic() 
    }); 
});