Callback after the DOM was updated in Meteor.js

Tags: meteor

I have this Meteor project:

It's basically a tool with a big textarea and a pre area that lets you enter source code snippets that automatically get pushed to all connected clients.

I'd like to automatically run the highlightSyntax function when the code was changed, but it doesn't really work.

I've tried query.observe, but that didn't work too well: The syntax highlight flashed up once and then disappeared again.

So my question is: How do I run code after the DOM was updated?


I think you might want to pass a callback to



It seems Template.myTemplate.rendered doesn't work properly or I don't get it...

I need to load TinyMCE inline after a template with all posts are rendered, so I have :

- a Template

By : Todo

I just found a little hack that seems to be working pretty well:

Template.myTemplate.onRendered(function() {
    this.autorun(function() {
        Meteor.setTimeout(function() {
            // DOM has been updated
        }, 1);

I'm not a Meteor expert so it might have some downsides, but I haven't found any for now — except that it's a bit dirty !

By : Nico Prat

This video can help you solving your question :)
By: admin