0
votes

Is it possible to create a Meteor event for template only?

For example:

'click': function(){}

This will work anywhere on the browser, whether or not the clicked element was part of the template. What if I want to register an event for the template only? Is the only way to achieve this by doing 'click #DOM_ELEM_NAME' ?

1

1 Answers

0
votes

Events are captured only within the template that defines them:

Template.leaderboard.events({
  "click .button": function (event) {
    console.log('Only buttons in the leaderboard template trigger this');
  }
});

You shouldn't need to put ids in event selectors. Read more at Event maps.