Search code examples
javascriptjquerytemplatesmeteormeteor-helper

Passing two class to meteorjs click event?


Passing two class to meteorjs click event. I have two buttons save and close which have same functionality and i want to target them using meteor events. I know i can assign them same class or create two separate events.

But is there any way to target it with something like below code.

//This does not work

Template.layout.events({
    'click .close .save': function() {
        //do something here
},

I can do this but is there any better way.

  Template.layout.events({
        'click .close': function() {
            //do something here
    },

  Template.layout.events({
        'click .save': function() {
            //do something here
    },

Solution

  • You just need to comma-separate the events:

    Template.layout.events({
        'click .close, click .save': function() {
            //do something here
    },