Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
46
rated 0 times [  48] [ 2]  / answers: 1 / hits: 17903  / 13 Years ago, fri, january 20, 2012, 12:00:00

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.


More From » wordpress

 Answers
27

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);

[#87888] Thursday, January 19, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zahrafrancisr

Total Points: 176
Total Questions: 105
Total Answers: 99

Location: Svalbard and Jan Mayen
Member since Sun, Sep 25, 2022
2 Years ago
;