Skip to content

Instantly share code, notes, and snippets.

@cannikin
Created August 26, 2015 17:16
Show Gist options
  • Save cannikin/2c0e4f6bad60b34776f4 to your computer and use it in GitHub Desktop.
Save cannikin/2c0e4f6bad60b34776f4 to your computer and use it in GitHub Desktop.
# app/views/posts/show.html.erb
<article id="post-<%= @post.id %>" class="post">
<h1><%= @post.title %></h1>
<%= @post.body %>
<small><%= @post.author %></small>
<section class="comments">
<h2>Comments</h2>
<%= render @post.comments %>
</section>
</article>
# app/views/comments/_comment.html.erb
<div id="comment-<%= comment.id %>" class="comment">
<h2><%= comment.author %></h2>
<%= comment.body %>
<small><%= comment.author %></small>
<a href="#" data-behavior="reply">Reply</a>
</div>
# app/assets/javascripts/app.comments.js
App.Comments = {
reply: function() {
# ...
}
};
$(document).on('click', '[data-behavior~=reply]', function(e) {
App.Comments.reply();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment