我的Meteor应用中有以下可重用组件:
<template name="action_button">
<div class="action-button-container pull-right">
<div class="btn btn-danger action-button js-action-button" title="{{this.buttonTitle}}">
<span class="glyphicon glyphicon-{{this.buttonIcon}}"></span>
</div>
<div class="action-button-title">{{this.buttonTitle}}</div>
</div>
</template>
Template.action_button.events({
'click .js-action-button': function(e, tmpl) {
e.preventDefault();
// ?
}
});
实例化如下:
<template name="my_main_template">
...
{{# action_button buttonTitle="save" buttonIcon="ok" }} {{/ action_button}}
...
</template>
将自定义onClick行为添加到此按钮的实例的最佳方法是什么?