I am getting started with Meteor, and adapting the todo example to include nested tag groups. I have the following HTML, which outputs each name of each tag group, plus the
"click selected":function(e){
// this._id
var doc_id = $(e.currentTarget).parent().parent().attr("uid")
console.log(doc_id)
},
//specify the each id in the div above the nearest #each
//this will work in events but not in helpers`
I'm not sure whether you can get parent template data, but in your event handler you can access DOM elements: event.currentTarget will get the clicked element. Then just use jQuery to access attributes. If needed, event.currentTarget.parentNode will get the parent element in the DOM.
Ex: I don't know where you put the tag class, but let's say it's the class of your div where data-taggroup is defined. Then you could get the tag name using:
$(event.currentTarget).attr('data-taggroup')
I found the solution to access parent data:
Template.nestedTemplate.events({
'click a.class':function(event,template){
var parentID = template.data._id;
console.log(parentID);
}
});
The .events handler function receives two arguments: event, an object with information about the event, and template, a template instance for the template where the handler is defined. Took me a really long time to figure this one out. Don't use the handlebars solution, it shows your data!