title: CKEditor Insert HTML
body: <ol>
  <li>I have a data from database.</li>
  <li>In my js file, I would like to change my CKEditor text editor's value.</li>
  <li>My value is raw html.</li>
  <li>I want this raw value to be written on an empty CKEditor text editor.</li>
  </ol>
  
  <p>I tried these but got an undefined function error all the time :</p>
  
  <pre><code>CKEDITOR.instances.myEditorID.insertHtml( '&lt;p&gt;This is a new paragraph.&lt;/p&gt;' );
  CKEDITOR.instances.myEditorID.setData( '&lt;p&gt;This is the editor data.&lt;/p&gt;' );
  </code></pre>
  
  <p>I tried this too but still undefined function error :</p>
  
  <pre><code>CKEDITOR.instances.YOUREDITORID.updateElement();
  alert( document.getElementById( 'YOUREDITORID' ).value );
  </code></pre>
  
  <p>Instead of myEditorID i tried 'editor', 'editor1', 'editor2' but still doesn't work for me.</p>
  
  <p>Thanks in advance.</p>
  
  <p>---Update---</p>
  
  <p>This is the html of my ckeditor text editor :</p>
  
  <pre><code>&lt;textarea id="myEditorID" name="myEditor"&gt;&lt;/textarea&gt;
  &lt;script type="text/javascript"&gt;
      $(function () {
          var myEditor = $('#myEditorID');
          myEditor.ckeditor({ 
          height: 200, 
          extraPlugins: 'charcount', 
          maxLength: 2000, 
          toolbar: 'TinyBare', 
          toolbar_TinyBare: [
               ['Bold','Italic','Underline'],
               ['Undo','Redo'],['Cut','Copy','Paste'],
               ['NumberedList','BulletedList','Table'],['CharCount']
          ] 
          }).ckeditor().editor.on('key', function(obj) {
              if (obj.data.keyCode === 8 || obj.data.keyCode === 46) {
                  return true;
              }
              if (myEditor.ckeditor().editor.document.getBody().getText().length &gt;= 2000) {
                  alert('You have reached the maximum char length');
                  return false;
              }
          });
      });
  &lt;/script&gt;
  </code></pre>