Meteor: how to access parent properties within nested templates?

前端 未结 3 1491
慢半拍i
慢半拍i 2020-12-15 09:58

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

3条回答
  •  死守一世寂寞
    2020-12-15 10:53

    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!

提交回复
热议问题