Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make readonly/disable tinymce textarea

I need to disable or make readonly a tinymce textarea at runtime.

like image 997
Ahmed-Anas Avatar asked Dec 14 '12 15:12

Ahmed-Anas


People also ask

How do you make TinyMCE readonly?

</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.

How do I disable TinyMCE editor toolbar?

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.

How do I re initialize TinyMCE editor?

Use tinymce. remove() method to remove TinyMCE editor from the HTML element and again call tinymce. init() on the selector to reinitialize.


2 Answers

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); 
like image 78
Thariama Avatar answered Sep 18 '22 18:09

Thariama


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');  
like image 38
grajsek Avatar answered Sep 22 '22 18:09

grajsek