Do Meteor and Iron Router have an event hook? Template.yield.rendered?

I think it might be something that would be very helpful.

If we had:

<template name="layout">

  {{> header }}

  {{> yield }}

  {{> footer }}

</template>

      

It would be nice to have something like

Template.yield.rendered = function() {
  // Do something after the yield has finished rendering
}

      

In addition to

Template.header.rendered = function() {
  // Do something after the header has finished rendering
}

Template.footer.rendered = function() {
  // Do something after the footer has finished rendering
}

      

+3


source to share


1 answer


If you really need to hook "any" pattern, you can define a nested crop pattern:

<template name="layout">

  {{> header }}

  {{> nested_yield }}

  {{> footer }}

</template>

<template name="nested_yield">
 {{> yield }}
</template>

      

then



Template.nested_yield.onRendered(function() {
  //your render code here
});

      

However, you may run into problems if the template ends up updating with the same template as IronRouter, caches the templates and will not actually "re-render" the template.

+1


source







All Articles