Reputation: 1109
Does anyone know what I'm missing the following example for it to work properly? Please check out the source code to see if you can help.
http://www.instructuk.com/tinymcee.htm
When you click the 'Edit Content' link, the TinyMCE opens up...no problems. When you click 'Cancel' button this cancels the window...no problems. When you click 'Ok' button it doesn't transfer the new content (anything typed in the TinyMCE editor) back to the original div box. However if you click 'Edit Content' again it has kept the edited text???
I'm using a function and various tag elements to call the TinyMCE instance because the idea is this will be used on multiple DIV boxes on the page.
Thanks.
Upvotes: 1
Views: 1566
Reputation: 50832
Looks like you need to make sure the editors content gets written back.
You should call on "ok"-click: tinymce.triggerSave();
to write back the editors content to the underlying textarea. Another option is to write it back using pure javascript when pressing the ok-button:
var content = tinymce.get(editorid).getContent();
$('#box1').html(content);
Edit: In reply to your comment.
This will be due to the fact that you remove the part of the dom where the editor is located at/in. In order to be able to reinitialize a tinymce instance with the same id as before you need to shut down tinymce regulary before you dump the part of the dom with the tinymce editor. For this you should removeControl
of this editor instance.
Upvotes: 1