Meteor Template events, how to get object that caused event?
meteor
Solution
Try this:
Template.problem.events = {
'click .problem-text' : function () {
var user_id = Session.get('user_id');
// how to get problem_id of clicked item?
Router.gotoProblem(user_id, this._id);
}
};
Problem
I have some code similar to the following: In myapp.html ``` <template name="problems"> <div class="problems"> {{#each problems}} {{> problem}} {{/each}} </div> </template <template name="problem"> <div class="problem"> <div class="problem-text" id={{_id}}>{{text}}</div> </div> </template> ``` In myapp.js ``` Template.problem.events = { 'click .problem-text' : function () { var user_id = Session.get('user_id'); // how to get problem_id of clicked item? Router.gotoProblem(user_id, problem_id); } }; ``` In this situation I want to get the id of the that matched .problem-text and was clicked. I would like to know the "object" that generated the event? How do I do this?