Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh tinymce iframe?

Tags:

tinymce

How can I refresh the tinymce content or refresh the tinymce iframe using jquery?

like image 493
Mohan Ram Avatar asked Dec 01 '10 13:12

Mohan Ram


People also ask

How do you reload TinyMCE?

You need to use the remove() API to detach TinyMCE from the DOM before you close your Modal window. You can then use init() again when the modal is recreated.

How do I display TinyMCE content in HTML?

The TinyMCE getContent and setContent methods You can do this using the getContent() API method. Let's say you have initialized the editor on a textarea with id=”myTextarea”. This will return the content in the editor marked up as HTML.

How do I know if my TinyMCE is empty?

You can do this to check if the content is empty without parsing html: var content = tinymce. get('tinymceEditor'). getContent({format: 'text'}); if($.


2 Answers

This code is used to refresh tinymce:

tinyMCE.execCommand("mceRepaint");
like image 64
Mohan Ram Avatar answered Sep 20 '22 08:09

Mohan Ram


You can use this statement to refresh (replace) the content:

editor.execCommand('mceSetContent', false, html);

Or if you want to make sure the dirty flag is cleared:

editor.execCommand('mceSetContent', false, html);
editor.startContent = tinymce.trim(editor.getContent({ format: 'raw' }));
editor.isNotDirty = true;
editor.nodeChanged();
like image 40
mhu Avatar answered Sep 22 '22 08:09

mhu