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.
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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With