public
Created

  • Download Gist
foo.js.erb
HTML+ERB
1 2 3 4 5 6 7 8
<% if @comment.persisted? %>
<% broadcast "/comments/new" do %>
$("#comments").append("<%= escape_javascript(render(@comment)) %>");
$("#new_comment")[0].reset();
// http://stackoverflow.com/questions/2653233/keeping-the-scroll-to-bottom
document.getElementById("comments").scrollTop = 10000;
<% end %>
<% end %>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.