Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set TinyMCE Editor Param after Initialized

I am trying to set the readonly parameter in tinyMCE to true after tinyMCE has been initalized. I am trying to use this with wordpress to disable the postEditor if the post has already been published. I found some sources claiming that you can call:

tinyMCE.activeEditor.execCommand(
    'mceSetAttribute',
    false,
    {name:'readonly',value:true}
);

but I have been having no luck with that and have not found a solution.

like image 487
Aramael Pena-Alcantara Avatar asked Jan 20 '12 18:01

Aramael Pena-Alcantara


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.


1 Answers

An easier way to set this is tinyMCE.activeEditor.settings.readonly = true; But the problem here is that the readonly setting affects the way tinymce gets initialized. So setting it after tinymce is initialized won't have a big impact.

What you can do to prevent users from editing content in your editor is to set the contenteditable attribute of the editors iframe body to false:

tinymce.activeEditor.getBody().setAttribute('contenteditable', false);
like image 158
Thariama Avatar answered Oct 20 '22 09:10

Thariama