Skip to content

Instantly share code, notes, and snippets.

@nicedawg
Last active February 28, 2020 04:35
Show Gist options
  • Save nicedawg/1a94805ef8141b48b16a0b2faf8d659b to your computer and use it in GitHub Desktop.
Save nicedawg/1a94805ef8141b48b16a0b2faf8d659b to your computer and use it in GitHub Desktop.
[Beginning Rails 6] Listing 9-4. The Updated New Comment Template in app/views/comments/new.js.erb
document.querySelector("#comments").insertAdjacentHTML("afterend", "<%= escape_javascript render partial: 'new' %>");
var comment_form = document.querySelector("#main form");
comment_form.style.opacity = 0;
setTimeout(function() {
comment_form.style.transition = 'opacity 1s';
comment_form.style.opacity = 1;
}, 10);
document.querySelector("#new_comment_link").style.display = 'none';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment