Meteor JS: How to do I create event handler for multiple selectors?

events, javascript, meteor

Solution

Try this:

Template.page.events({
  'click h1, click h2, click h3, click h4, click h5, click h6' : function (e, template) {
    console.log("clicked");
  }
}

I believe event maps do not support comma separated selectors because commas are used to delimit individual event names or `event selector` pairs.

Problem

I am trying to create the same event handler for multiple elements, but cannot find anywhere in the documentation to do this. In the below example, I am trying to create a click handler for all text handings. This works for `h1`, but not for the rest. ``` Template.page.events({ 'click h1, h2, h3, h4, h5, h6' : function (e, template) { console.log("clicked"); } } ```

Original source