Use .onRendered for global?

I create the Blaze Layout

<template name="appLayout">
  {{> Template.dynamic template=main }}
</template>

Could I use template level

Template.main.onRendered();
......................onCreated();
...........

Maybe I do not quite understand your question, but in the above example, you also will have

<template name="main">
  <!-- content -->
</template>

And of course, that may use its onRendered() etc.

I use FlowRouter, BlazeLayout and fezvrasta:bootstrap-material-design.
I would like to init the $.material.init(); for all of content template rendered.
But I do this many time on the all content
Ex:

<template name="home">
</template>

Template.home.onRendered(...$.material.init();...);
-------------------------
<template name="about">
</template>

Template.about.onRendered(...$.material.init();...);
-------------------

So I want to config this for all.
Please help me.

So you are looking for ONE global Template.all.onRendered() hook which is done everytime a template gets created, rendered, … ?

P.S.: In that case you should change your title and question and use your second comment instead

Thanks for your advice, please example for me.

Google is your friend if look for the right question:

see: http://stackoverflow.com/questions/26281201/render-callback-to-all-templates-in-meteor-blaze

Look great, thanks again.
Excuse me, this solution make the project slow or not?

Why should it?

It just inserts an additional onRendered function to your templates.

Same as you can do like

Template.main.onRendered(function () {
  // do this
});

Template.main.onRendered(function () {
  // do that
});

A template may gets registered more than one function.

The Meteor.startup() will just insert that function once on startup.


Update: At least any line of code will slow down your app. Best app in case of performance is:

function main() {}

:wink:

Thanks again for your helping.