Created
August 26, 2015 17:16
-
-
Save cannikin/2c0e4f6bad60b34776f4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 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