Hi. I couldn’t find a way to access child templates. I have an “item” template that can have many child “item” templates inside and I need to access them. Is there a way to do it?
Also there’s no easy way of accessing parent templates other than using custom function with some kind of iteration through the parents. Am I correct?
If this is the case I think this is a very big missing feature in Blaze.
@orbyt That tutorial only talks about accessing parents, but not children. Even to access parents I have to create my own function or use aldeed’s package.
You asked: [quote]Also there’s no easy way of accessing parent templates other than using custom function with some kind of iteration through the parents. Am I correct?[/quote]
@orbyt sorry if I wasn’t clear in my question. I can access parent templates but I use a function like this (that I got from someone I don’t remember in what forum):
Blaze.TemplateInstance.prototype.searchParentTemplate = function (levels) {
var view = Blaze.currentView;
if (typeof levels === "undefined") {
levels = 1;
}
while (view) {
if (view.name.substring(0, 9) === "Template." && !(levels--)) {
return view.templateInstance();
}
view = view.parentView;
}
}
This shouldn’t be this hard. Hopefully the meteor guys will solve it in the seemingly upcoming the componets package.
The manuel:viewmodel package (for children/parent/sibling/accesing helpers) and using _uihooks (to have control on changes in the DOM inside a template) solved all my problems with Blaze.