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.
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.
Share Improve this question edited Jan 20, 2012 at 20:56 Charles 51.4k13 gold badges106 silver badges144 bronze badges asked Jan 20, 2012 at 18:51 Aramael Pena-AlcantaraAramael Pena-Alcantara 3681 gold badge3 silver badges9 bronze badges1 Answer
Reset to default 17An 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);