:
Template, ( ) . , .
, - JS :
chatBox.js
Template.chatBox.helpers({
chatMessages: function() {
return Conversations.find({conversationId: conversationId},
{sort: {d: -1}, limit: 20}).fetch().reverse();
},
});
(chatMessages.d conversationId , , chat-messages div, 20 )
, :
Template.chatBox.helpers({
chatMessages: function() {
$('#chat-messages').scrollTop($('#chat-messages').prop('scrollHeight'));
return Conversations.find({conversationId: conversationId},
{sort: {d: -1}, limit: 20}).fetch().reverse();
}
});
:
Template.chatBox.helpers({
chatMessages: function() {
//scroll down with animation
$('#chat-messages').animate({scrollTop: $('#chat-messages').prop('scrollHeight')}, 500);
return Conversations.find({conversationId: conversationId},
{sort: {d: -1}, limit: 20}).fetch().reverse();
}
});
" " .
, .