I'm using Collections.observe in my chat app. After submitted one message, all the users needs to be scrolled down to appear the new message.
I am trying:
Messages.find().observe({
added: function() {
$('.messages').scrollTop($('.messages')[0].scrollHeight); // scroll to bottom
}
});
However, this function execute before the message appears in the screen. But I need the observe function to execute AFTER the message appears on the screen, to scroll down. How can I do that?
Maybe you should use
this.autorun()
in anonRendered
event in template with.messages
elem. I mean something like: