Forum Discussion

Akenefick's avatar
Akenefick
Genius
4 years ago

Preloaded Text In Tinymce Editor

I am trying to create a component to add to the PostPage that will prefill the text editor with some questions to answer when posting an idea. I tried using this  tinymce.activeEditor.setContent("<...
  • Claudius's avatar
    4 years ago

    This is probably what you are looking for.

    tinyMCE.get('tinyMceEditor').execCommand('mceInsertContent', false, '<p>Test Question One<br><br><br>Test Question Two</p>');

    Keep in mind that this will only work after the editor has initialized properly. Good way to ensure is by wrapping it like that so that it will run once the Khoros jQuery object is present:

    <@liaAddScript>
      ;(function($) {
        tinyMCE.get('tinyMceEditor').execCommand('mceInsertContent', false, '<p>Test Question One<br><br><br>Test Question Two</p>');
      })(LITHIUM.jQuery);
    </@liaAddScript>