Skip to content

Instantly share code, notes, and snippets.

@SachaG
Created September 9, 2012 04:01
Show Gist options
  • Save SachaG/3682499 to your computer and use it in GitHub Desktop.
Save SachaG/3682499 to your computer and use it in GitHub Desktop.
// in comment_list.js
Session.set('comments_rendered', false);
Template.comment_list.rendered = function(){
var numberOfComments=Comments.find({post: Session.get('selected_post_id')}).count();
var commentsRendered=this.findAll(".comment").length;
if(numberOfComments==commentsRendered){
console.log(numberOfComments+" comments rendered");
Session.set('comments_rendered', true);
}
}
// and then in comment_item.js
Template.comment_item.rendered_class = function(){
if(Session.get("comments_rendered")){
// comments have already been rendered in the DOM, so queue this one instead
return "queued";
}
// comments are still being rendered initially, so just display it normally
return "opened";
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment