Forum Discussion
Just checked on the live Spotify community, and the code works for me. You need to make sure the code runs after the document has loaded.
Stumbled across another way of setting the content:
tinyMCE.activeEditor.setContent("Hello world!")
Found this in the Lithium core JavaScript code. It works when I run it from the console on the private message page.
In the console it runs just fine, but if I put the script in the header, nor the footer.
The tinymce editor sort of blips when it's done loading itself. I think it' firing some of its own code near the end, which I think is interrupting other code. This doesn't work:
$(document).ready(function () { LITHIUM.jQuery('#tinyMceEditor_ifr').contents().find('#tinymce').html('<p>Hello World!</p>') });
- PaoloT11 years agoLithium Alumni (Retired)
Hi PerBonomi
I haven't tried myself - but I think TinyMCE has also a "init" event that you need to observe before executing extra logic, to ensure your custom script runs when the editor is fully initalized.
Thanks,
- nathan11 years agoExecutive
Good point PaoloT
The documentation for the init event is here:
http://www.tinymce.com/wiki.php/API3:event.tinymce.Editor.onInit
- PaoloT11 years agoLithium Alumni (Retired)
Just a word of caution, the documentation linked above is for TinyMCE 3.x , but we recently upgraded to 4.x so it may differ between communities etc ...