user1952811
user1952811

Reputation: 2458

Context change events won't work Meteor

So i've got a structure like this

<template name="example">

{{#each post}}
<div class="hello"></div>
{{/each}}

</template>

So now I am trying to check for click events on the hello div like so

Template.example.events = {
  'click .hello' : function(event) {

     console.log("hey");

  }    
}

But this is not working. Console is not logging anything.

Does this have to do anything with the change of context in the html template?

Upvotes: 0

Views: 49

Answers (1)

sbking
sbking

Reputation: 7680

events is a function that you need to pass an event map to. Right now you are assigning an event map and overriding the actual events method. Try this:

Template.example.events({
  'click .hello' : function(event) {
     console.log("hey");
  }    
});

Upvotes: 1

Related Questions