javascript - Meteor.js: Execute method after list has been populated -
i started working on meteorite bundle adds groups/headlines lists. see demo here. source code demo here.
basically, want wait list exclusively populated , phone call method sets headlines/groups etc. way calling handlebars helper after {{#each}}
loop, this:
<ul> {{#each listitems }} {{> listitem }} {{/each}} </ul> {{ grouplist }}
where grouplist
helper executes code want run efter loop gets run (the code sets headlines).
this feels kind of ugly, , think prefer kind of callback {{#each}}
loop gets called after it's finished iterating (and importantly if items in loop change). sort of rendered() method templates guess. (and i've of course of study tried rendered() method already, get's executed before loop run.)
is there such callback? or other technique less ugly 1 utilize handlebars helper?
rather letting blaze render list , using jquery add together headers, grouping , headers in template itself, this:
class="lang-html prettyprint-override"><template name="grouped"> {{#each groups}} <h2>{{heading}}</h2> {{#each items}} {{> item}} {{/each}} {{/each}} </template>
class="lang-js prettyprint-override">template.grouped.groups = function () { homecoming _.chain(listitems.find().fetch()) .groupby("wins") .pairs() .map(function (pair) {return {heading: pair[0], items: pair[1]};}) .value(); };
this seems more 'meteoric' me - imperative dom manipulation wrong approach in meteor. i'm not sure how performance compares.
javascript meteor
No comments:
Post a Comment