【发布时间】:2015-12-29 08:40:38
【问题描述】:
我不想使用 jQuery,而是想将回调绑定到 Semantic-UI 模块的“Meteor-way”,有点像 Bootstrap 3 允许的,例如:
Template.someTemplate.events({
'show.bs.dropdown .someDropdown': function () {
// official Bootstrap JS callback for the Dropdown module's show event
}
});
使用 Semantic-UI 似乎我只能在包含模板的 onRendered() 回调中使用 jQuery 绑定时定义回调函数,例如:
Template.someTemplate.onRendered( function () {
this.$('.someDropdown').dropdown({
'onShow': function () {
// official Semantic-UI JS callback for the Dropdown module's show event
}
});
});
这不是最优的,因为 (a) 在特定模板的 onRendered() 回调期间其他 DOM 元素可能还没有准备好进行操作,并且 (b) 它使得关注点分离和代码清晰变得更加难以实现。
有没有办法使用 Meteor 的 Template.events 绑定这些事件,如果是,那么正确的语法是什么?
谢谢。
【问题讨论】:
标签: javascript jquery meteor meteor-blaze semantic-ui