Controlling JS load order in Meteor with nested templates breaks with template.rendered? -
i've got template named index
made of bunch of partial templates.
<template name="index"> {{> jumbotron }} {{> crew }} {{> projects3 }} {{> projects2 }} {{> faq }} {{> contact }} </template>
say i've got js code page-transitions.js
requires dom of jumbotron
loaded in order run.
it's not plenty simple do:
template.index.rendered = function(){ // load page-transitions.js };
i have
template.jumbotron.rendered = function(){ // load page-transitions.js here instead };
this can messy quick because need specific partial templates need js code. , different templates require same js code can run situation you're loading same js code multiple times.
is there way wait until index
template has rendered everything, including nested kid templates, , run js code?
meteor.startup()
doesn't work in case either.
you can seek couple of things:
first, utilize classic jquery.ready
way. because, why not?
meteor.startup(function() { $(document).ready(function() { // stuff. }); });
or seek tracker.afterflush
:
meteor.startup(function() { // know each template.template.rendered has own afterflush, // computations defined way before meteor.startup then, theoretically, // below code should executed lastly if triggers recomputations here. tracker.afterflush(function() { // stuff. }); });
meteor
No comments:
Post a Comment