Skip to content

Instantly share code, notes, and snippets.

@fbatista
Created August 30, 2012 14:12
Show Gist options
  • Select an option

  • Save fbatista/3529349 to your computer and use it in GitHub Desktop.

Select an option

Save fbatista/3529349 to your computer and use it in GitHub Desktop.
Partial live updates issue
posts_frag = Meteor.ui.render ->
Meteor.ui.listChunk Posts.find({}, {sort: {created_at: -1}}),
(post)->
comment_frag = Meteor.ui.listChunk Comments.find({post_id: post._id}, {sort: {created_at: -1}}),
(comment)->
Template.comment comment
post.comments = new Handlebars.SafeString comment_frag
Template.post post
$('#post_list').append(posts_frag)
<body>
<div class="container">
<div class="row">
<div id="main" class="span8 offset2">
{{> posts}}
</div>
</div>
</div>
{{> navigation}}
</body>
<template name="posts">
<section id="post_list">
</section>
{{#if currentUser}}
{{#if currentUser.admin}}
<section id="create_post">
{{> create_post}}
</section>
{{/if}}
{{/if}}
</template>
<template name="post">
<article>
<div class="header_wrap">
<!-- navigation, header, action buttons, etc. basically stuff i dont want to be updated when new comment gets added -->
</div>
<div class="article_body">
{{#markdown}}{{body}}{{/markdown}}
</div>
<div class="comments well">
{{comments}}
</div>
</article>
</template>
<template name="comment">
<div class="comment">
{{#markdown}}{{body}}{{/markdown}}
<!-- footer -->
</div>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment