Created
October 15, 2015 09:58
-
-
Save sizovilya/9d848474d20f01071c82 to your computer and use it in GitHub Desktop.
self.autorun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Template.messages.helpers({ | |
'messages': function(){ | |
return roomComments.find(); | |
}, | |
'members': function(){ | |
var members = Posts.find({roomId:Session.get('selectedChat')},{fields:{members:1}}).fetch()[0].members; | |
return members; | |
} | |
}); | |
Template.messages.onRendered(function() { | |
var self = this; | |
self.autorun(function() { | |
self.subscribe('messages', Session.get('selectedChat')); | |
}); | |
function scrollDown(){ | |
$('.chats-item-messages').stop().animate({ | |
scrollTop: $(".chats-item-messages")[0].scrollHeight | |
}, 800); | |
} | |
roomComments.find().observeChanges({ | |
'added':function(id,doc){ | |
scrollDown(); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment