I am building basic chat application just to try out meteor. When user enters a chat channel, it would be logical to show him the latest messages that are at the bottom. Right now I am trying to achieve this with following code
Template manager
Template.messages.rendered = function(){
var message_container = this.find('.messages');
var height = message_container.scrollHeight;
$(message_container).animate({scrollTop: height}, 1000)
};
Template
<template name="messages">
<div class="messages">
{{# each messages}}
{{> message}}
{{/each}}
</div>
</template>
The problem is the code in template manager is being executed, while not all messages have been rendered, thus it results in incorrect height, in var height.