John Magnolia John Magnolia - 4 months ago 17
Javascript Question

Tinymce auto set readonly if the textarea has readonly

How would I set tinymce to automatically set the editor as readonly if the

textarea
already has the
attr("readonly")

Answer

A more general solution might be

tinyMCE.init({
    ...
    setup: function(ed) {
        if($('#'+ed.id).attr('readonly'))
            ed.settings.readonly = true;
    }
});

This will work for all textareas without you having to specify any ids. In addition it will actually set the editor to readonly mode, and not only prevent editing.

Comments