I’m currently using tinymce as a html text editor in a rails application and I’m currently facing a problem. I’m unable to set the text of the html editor to a desired text. I’m using javascript to change the text of the editor. Instead of text being set in the editor, it just brings myself to the top of the html page. I’ve checked and confirmed that the file exists and being put in the correct directory. May I know how to solve this The following are my codes:
templates.html
<table>
<tr>
<td><%=image_tag("template01.png", :class => "template")%></td>
<td><%= link_to_function "Use Template", " tinyMCE.activeEditor.setContent('" + File.read("app/assets/template_01.html") + "')"%></td>
</tr>
</table>
I suggest you output/log
" + File.read("app/assets/template_01.html") + "and then verify if the result is really what you want.Be aware that
tinyMCE.activeEditorwill be a defined value after anyone clicked inside the editor! It might be the better choice to usetinymce.get('your_editor_id')here.