Marcus Riemer
Marcus Riemer

Reputation: 7688

How do I run jQuery plugins with Meteor 0.8 (Blaze) on template changes?

I am aware of this very similar question but I can't wrap my head around my corner case. In my situation, I need run those jQuery plugins unconditionally as I can't narrow down the potentially affected DOM nodes. My old code looked like this:

Template.Main.rendered = function() {
  jQuery('time.timeago').timeago();
}

But with the new layout engine the rendered events won't "bubble up" to my Main template which means that timestamps won't be updated to human readable representations.

Upvotes: 0

Views: 282

Answers (1)

Marcus Riemer
Marcus Riemer

Reputation: 7688

Nevermind, I found a very fine approach at Meteorpedia. No idea why I didn't think of it ...

<template name="TimeAgo">
  <time class="timeago" datetime="{{this}}" title="{{this}}">{{this}}</time>
</template>

Template.TimeAgo.rendered = function() {
  this.$('time.timeago').timeago();
}

Upvotes: 1

Related Questions