How to get the parent template instance (of the current template)

前端 未结 5 2174
抹茶落季
抹茶落季 2020-12-03 10:55

Is there a clean way to get the parent template of the current template? Nothing is officially documented in Meteor\'s API. I\'m talking about the Blaze.TemplateInstan

5条回答
  •  醉话见心
    2020-12-03 11:34

    If you don't want to extend Blaze.TemplateInstance you can access the parent instance like this:

    Template.exampleTemplate.onRendered(function () {
      const instance = this;
      const parentInstance = instance.view.parentView.templateInstance();
    });
    

    Only tested in Meteor 1.4.x

提交回复
热议问题