net.user
net.user

Reputation: 831

meteor: how to use multiple classes in css selector

This works well in meteor.

Template.xxx.events = {
'click .btn-plus': function(event) {}
}

But in this example, the event were never fired.

Template.xxx.events = {
'click .btn.btn-success.btn-mini.btn-plus.pull-right': function(event) {}
}

Why you can't use multiple classes as selector? i need to identify the button on the .btn-plus class.

regards, cid

EDIT:

My temporary solution:

HTML-file:

<div class="btn-plus">
  <button class="btn btn-primary btn-mini pull-right">Caption</button>
</div>

JS-file:

Template.xxx.events = {
  'click .btn-plus': function(event) {}
}

Upvotes: 0

Views: 1544

Answers (2)

Alex Bierach
Alex Bierach

Reputation: 31

http://docs.meteor.com/#eventmaps

Template.xxx.events({
   'click .btn, click .btn-success, click .btn-mini, click .btn-plus, click .pull-right': function(event) {
      console.log("clicked a button");
   }
}

There is another page addressing this question here: Meteor JS: How to do I create event handler for multiple selectors?

Upvotes: 2

Ian Atkin
Ian Atkin

Reputation: 6356

I just took a quick peek at the docs. I think this will work...

Template.xxx.events = {
    'click .btn .btn-success .btn-mini .btn-plus .pull-right': function(event) {}
}

Upvotes: 2

Related Questions