How to disabled or non-editable text editor using CSS or jQuery?

Viewed 916

I am using a rich text editor on my portal. Is there any way not to edit this without permission from the admin? I mean can we disabled it?

I also testing this jQuery rich text

I tried the below code but it's still allowing me to edit.

HTML

  <textarea class="contenteditor1 disabledme" name="message"  hidden="hidden"><?php echo $info['message'];?></textarea>

jquery

$('.disabledme').attr('disabled', 'disabled');
3 Answers

If you look rich text editor HomePage you will know that there is a future ReadOnly

 editor1.setReadOnly(true);

This will disable the textEditor.

Read more about this here

Here is the proper solution, you need to edit the few lines of code:

  1. First in your main index.html file you have to pass two arguments, one blank and one with either true or false, true means editable and false means not editable.

$('.content').richText('',false);

  1. Than in your jquery.richtext.js file on line at 27 add one more argument (iseditable) in function like below:

$.fn.richText = function (options,iseditable) {

  1. Than on same jquery.richtext.js file at line 535 replace the whole line with the below code like this:

var $editorView = $('', {class: "richText-editor", id: editorID, contenteditable: iseditable});

to set readonly true

    data.attr("readonly",true);

to set readonly false

    data.attr("readonly",false);
Related