i put this in my html
<div class=“testclass”>
testclass click
</div>
and this in the js.
Template.templatename.events({
"click .testclass": function (event) {
alert("hello");
}
});
–> it works fine.
but i am using this class in many templates, so i figured i use template.body.events instead (like in the tutorial with a form):
Template.body.events({
"click .testclass": function (event) {
alert("hello");
}
});
–> nothing happens.
so template.body.events is not a way to globally ‘listen’ to events?
how is it then possible to create a class and assign it a behaviour throughout many templates?
otherwise i would have to write the same code for multiple templates.
thanks in advance.