Search code examples
javascriptjquerytinymce

Change tinyMce editor's height dynamically


I am using tinymce editor in my page. What I want to do is to change the height of the editor dynamically. I have created a function:

function setComposeTextareaHeight()
{
    $("#compose").height(200);
}

but that is not working. My textarea is

<textarea id="compose" cols="80" name="composeMailContent" style="width: 100%; height: 100%">

I have tried all sorts of methods for changing the height but could not come to a resolution. Is there any thing that i am missing?


Solution

  • You can resize tinymce with the resizeTo theme method:

       editorinstance.theme.resizeTo (width, height);
    

    The width and height set the new size of the editing area - I have not found a way to deduce the extra size of the editor instance, so you might want to do something like this:

       editorinstance.theme.resizeTo (new_width - 2, new_height - 32);