Created
September 9, 2012 04:01
-
-
Save SachaG/3682499 to your computer and use it in GitHub Desktop.
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
// 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