Best way to execute function after new element?


Hey guys,
I’m now having a little problem with adding “new elements” and exeuting a function after it. For example, I have this template.

{{#each getMessages}}
    <div class="message animated fadeIn {{#if this.own}}me{{/if}}">
        <div class="image">
            <img src="...">

    <p class="clear"></p>

Okay, my helpers return a reactive-array:{

'getMessages': function () {

       $("#chatDiv").mCustomScrollbar("scrollTo", "last");
    return userMessages.list();

As you can see, I execute a 500ms delay to scroll to the bottom of my chat div. Is there any better way without using a mauel time delay?


I use Tracker.flush() and Meteor.defer but that’s the same (hacky) idea.


Maybe using _uihooks? See:


I would personally do this in as a sub template and then use the onRendered callback. You can see an example of this here.