I have a situation where I partially recycle Handlebars based on the Mongodb tree structure, something like this:
<template name='menu'>
<ul class='menu'>
{{#each topLevelChildren}}
{{>menu-item}}
{{/each}}
</ul>
</template>
<template name='menu-item'>
<li>{{name}}
{{#if listChildren.count}}
<ul>
{{#each listChildren}}
{{>menu-item}}
{{/each}}
</ul>
{{/if}}
</li>
</template>
where the mongodb docs look like this:
{ _id : ObjectId("525eb7245359090f41b65106"),
name : 'Foo',
children : [ ObjectId("525eb60c5359090f41b65104"), ObjectId("525eb6ca5359090f41b65105") ]
}
and listChildren simply returns a cursor containing complete documents for each item in the parent's child array.
I want to do a bit of jquery makeup on a rendered tree, but I can't seem to hook into the "rendered" event for the whole tree, something like
Template.menu-completed.rendered = function(){
}
Attempt this
Template.menu.rendered = function(){
console.log($('menu li'));
}
This not only returns the correct results (the brackets are filled with commas), but also freezes the web inspector (but not the application ...). Any help would be greatly appreciated!