Newb me again with a question about the best method for retrieving references for DOM elements and their corresponding database entries.
For example, in my checkin checkout app I need to be able to retrieve the database id for the employee which was clicked in a list so I can update his/her status boolean in the database.
When I use the following code:
Template.employeeList.events({
'click img': function(){
console.log("You clicked an indicator." );
var clickElement = event.Target;
var clickOther = event.currentTarget;
console.log(clickElement);
console.log(clickOther);
},
'change textArea': function(){
console.log("You have changed the text area.");
}
});
all event handlers in meteor receive two arguments: the event and which template instance it happened in
Template.employeeList.events({
'click img'(event, instance) {
// instance.data will give you access to the data context
// to get the actual DOM handle for the clicked img scope the $ to the instance
var img = instance.$(event.currentTarget);
},
});