barbatus / stars-rating

Stars rating control for Meteor
MIT License
21 stars 11 forks source link

can't access userrating via a class, only by id #11

Closed andrewlorenz closed 8 years ago

andrewlorenz commented 8 years ago

hi, I'm having no problem accessing the current userrating by id (as per your usage notes) - but can't seem to access the same userrating via a class. In fact, no matter what I try in the click event, I can't seem to access it. But I want to use the star rating for multiple items in a loop so I can't use id!

e.g. {{> starsRating rating=4 size=22 mutable=true id="startest" class="startest"}}

'click .startest': function(event,template) { $('#starest').data() = works fine via $(this) = no good via event.target = no good via event.currentTarget = no good

andrewlorenz commented 8 years ago

actually, I've worked out how to do it - and documenting here in case it helps others:

{{> starsRating rating=4 size=22 mutable=true class="startest"}}

Template.[templateName].events({ 'click .startest': function(event,template) { let rating = $(event.currentTarget).data('userrating'); } });