title: How do I load CKEditor with Javascript?
body: <p>I have integrated CKEditor into my commenting system for my blog, and it shows up fine when I load a new page. </p>
  
  <p>However, for reply comments, I have a javascript action that opens a new comment form from a "reply to this comment" link below each comment. In this case, the CKEditor doesn't load (I just get a basic non-CKEditor text-area). Do I need to add something to my javascript file so that the CKeditor loads correctly?</p>
  
  <p><strong>posts/show.html.erb</strong></p>
  
  <pre><code>&lt;%= @post.content %&gt;
  &lt;%= render 'comments/form' %&gt; #this CKEditor form renders fine when the page loads
  &lt;%= @post.comments %&gt;
  </code></pre>
  
  <p><strong>comments/_form.html.erb</strong></p>
  
  <pre><code>&lt;%= simple_form_for(@comment, remote: true) do |f| %&gt;
    &lt;%= f.hidden_field :parent_id %&gt;
    &lt;%= f.cktext_area :content, :input_html =&gt; { :ckeditor =&gt; { :toolbar =&gt; 'Basic' } }, :class =&gt; "comment_input" %&gt;
  &lt;%= f.button :submit %&gt;
  </code></pre>
  
  <p><strong>comments/new.js.erb</strong></p>
  
  <pre><code>$('#comment_&lt;%= @comment.parent.id %&gt;').append("&lt;%= escape_javascript(render 'form') %&gt;");
  </code></pre>
  
  <p><strong>comments/_comment.html.erb</strong></p>
  
  <pre><code>&lt;div id="comment_&lt;%= comment.id %&gt;"&gt;
    &lt;%= comment.content.try(:html_safe) %&gt;
    &lt;%= link_to "reply to this comment", new_comment_path(:parent_id =&gt; comment), remote: true %&gt;
  &lt;/div&gt;
  </code></pre>