1

Topic: Enable / Disable Tinymce

Hi,

I want to disable and enable the tinymce editor through javascript. I found that I can add the readonly:true option and it becomes disabled.

The problem is that I want to enable it again and I don't know how.

Any help and suggestions are appreciated.

Thanks

Damian

2

Re: Enable / Disable Tinymce

dejmjin wrote:

Hi,

I want to disable and enable the tinymce editor through javascript. I found that I can add the readonly:true option and it becomes disabled.

The problem is that I want to enable it again and I don't know how.

Any help and suggestions are appreciated.

Thanks

Damian

Do you mean you want to toggle between "editable" and "read only", or do you want to toggle between the whole editor and the textarea it replaces?

"Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov

3

Re: Enable / Disable Tinymce

Use

tinyMCE.execCommand('mceRemoveControl', false, editor_id);

to shut down tinymce and to reinitialize it use

tinyMCE.execCommand('mceAddControl', false, editor_id);

to toggle use

tinymce.get(editor_id).hide();

and

tinymce.get(editor_id).show();

Last edited by stefanw (2011-06-16 17:02:08)

4

Re: Enable / Disable Tinymce

@Krupski: I want to toggle between "read only" and "editable"

@stefanw: Thank you for your help, but I still did not succeed in fixing this.


My textarea html is like the following:

 <asp:TextBox ID="elm1" Width="100%" Rows="60" runat="server" TextMode="MultiLine"></asp:TextBox> 

I created the following two javascript functions

function Hide() {
            tinymce.get('elm1').hide();
        }
        function Show() {
            tinymce.get('elm1').show();
        }

and created two anchors

 <a href="#" onclick="Hide();">Hide</a>
        <a href="#" onclick="Show();">Show</a>

when I use the mcRemoveControl and mceAddControl functions in the functions, nothing happens but when I use the show and hide, it gives me an error that it cannot convert 'tinymce.get('elm1')' to object.

any help please?

thank you

5

Re: Enable / Disable Tinymce

Hi there,

I'm replying to this thread as it's one of the most recent on the subject. I need to disable TinyMCE while *still retaining the controls* in the display.

I have found a mix of attempts at stackoverflow (http://stackoverflow.com/questions/3455 … s-textarea) and here at the TinyMCE forums (http://www.tinymce.com/forum/viewtopic.php?id=26995).

The latter works the best so far, in that everything *looks* disabled and I cannot type into the Instance. However, I am able to place the cursor (something that http://www.tinymce.com/tryit/read_only_mode.php prevents, I notice), and when I can place the cursor the paragraph alignment and un/link controls become enabled - when I use those, so to does the un/redo controls. I am also able to use keyboard shortcuts to perform any task they usually allow - and right-click.

All of this assumes the instance is visible, if not - DOM exception.

Is there yet a way to completely disabled a TinyMCE instance, while retaining all controls etc on screen?

6

Re: Enable / Disable Tinymce

anyone found an answer for this issue please?

7

Re: Enable / Disable Tinymce

for anyone who did not find an answer, this is my workaround..

if (tinyMCE.activeEditor != null) {
        if (myCondition) {
            tinyMCE.activeEditor.execCommand('mceSetContent', false, '<p><div class="mceNonEditable">' + myContent + '</div></p>'); //make read only
        }
        else {
            tinyMCE.activeEditor.execCommand('mceSetContent', false, myContent); //editable
        }
    }