title: What is the correct way to copy/paste an innerHTML by javascript to a textarea input, managed by CKEditor, include in a simple_form_for on Rails?
body: <p>I have succeeded to implement CKEditor (<a href="https://github.com/galetahub/ckeditor/" rel="nofollow noreferrer">https://github.com/galetahub/ckeditor/</a>) in an input textarea of a rails new/edit simple_form_for. It works well. But I have some javascript code which copy an innerHTML somewhere to paste it in the input textarea managed by CKEditor, and this not working. I don't find the right &quot;id&quot; or &quot;class&quot; in this input to use with a querySelector in order to paste my innerHTML. I have already tried with .content-input , #substep_content , .substep_content and .cke_editable, but it doesn't work. Someone can help me, please ?</p>
  <p>Here is the form :</p>
  <pre><code>&lt;%= simple_form_for(@substep) do |f| %&gt;
      &lt;%= f.input :content, label_html: { class: &quot;content-label&quot; }, input_html: { rows: 15, class: &quot;content-input&quot;, ckeditor: { toolbar: 'Full' } }, as: :ckeditor %&gt;
  &lt;% end %&gt;
  </code></pre>
  <p>When I open &quot;page source code&quot; :</p>
  <pre><code>&lt;div class=&quot;form-group ckeditor optional substep_content&quot;&gt;
   &lt;label class=&quot;ckeditor optional content-label&quot; for=&quot;substep_content&quot;&gt;Contenu&lt;/label&gt;
   &lt;textarea rows=&quot;15&quot; class=&quot;ckeditor optional content-input&quot; name=&quot;substep[content]&quot; id=&quot;substep_content&quot;&gt;&lt;/textarea&gt;
   &lt;script&gt;
   //&lt;![CDATA[
   (function() {
              if (typeof CKEDITOR != 'undefined') {
                if (CKEDITOR.instances['substep_content']) { CKEDITOR.instances['substep_content'].destroy(); }
                CKEDITOR.replace('substep_content', {&quot;toolbar&quot;:&quot;Full&quot;,&quot;customConfig&quot;:&quot;/assets/ckeditor/config-dff8e9963191c33e28d6d4ccec8784c5b317df36f5ae95a4f171ca46bd9f1df2.js&quot;});
              }
            })();
   //]]&gt;
   &lt;/script&gt;
  &lt;/div&gt;
  </code></pre>
  <p>Here the :</p>
  <p><a href="https://i.stack.imgur.com/NHMBx.png" rel="nofollow noreferrer">Image of inspector / examine the item</a></p>
  <p><strong>EDIT 2020/07/15 :</strong>
  I have found the solution in the API docs (see code below).</p>
  <pre><code>CKEDITOR.instances['substep_content'].setData( textContent );
  </code></pre>