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("<p>Test Question One<br><br><br>Test Question Two</p>");
I also tried
document.getElementById("tinymce").innerHTML = "<p>Test Question One<br><br><br>Test Question Two</p>";
I tried saving a .js file to "Other Assets" so I could "defer" the execution until after the page loads in case that was the issue.
I found this great post Default template for suggesting an idea in Idea Ex... - Atlas (khoros.com) by PerBonomi and tried to use his code minus the category check.
In every case the editor remains blank. Any idea where I might be going wrong? Thanks
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>