I need to disable or make readonly a tinymce textarea at runtime.
</p></textarea> <br><br> <label class="container">Editable ("design") mode <input type="checkbox" checked onclick="toggleEditorMode(this. checked); return true;"> <span class="checkmark"></span> </label> <br> Use the checkbox to toggle between the "design" and "readonly" modes.
statusbar. This option allows you to specify whether or not TinyMCE should display the status bar at the bottom of the editor. To disable the status bar, the statusbar option should be provided with a boolean false value.
Use tinymce. remove() method to remove TinyMCE editor from the HTML element and again call tinymce. init() on the selector to reinitialize.
Use the configuration parameter readonly
tinyMCE.init({ ... theme : "advanced", readonly : 1 });
Here is a link to a demo.
Update: 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);
From version 4.3.x on you can use code below for readonly mode
tinymce.activeEditor.setMode('readonly');
and for design mode:
tinymce.activeEditor.setMode('design');
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