How to show / hide CKEditor using JQuery? #CKEditor_tip


Updated September 4, 2015 ‚óŹ 4,204 views

CKEditor will not be editable after you hide an element, even the parent div. To go around this, you need to destroy the CKEditor instance first then define it again.

For example:

//first check if textarea element already a CKEditor, then destroy it
if(typeof CKEDITOR.instances['element_name'] != 'undefined') {
    CKEDITOR.instances['element_name'].updateElement();
    CKEDITOR.instances['element_name'].destroy();
}

//make the textarea element a CKEditor
CKEDITOR.replace( 'element_name' );

//show hidden element, in this case a div element was hidden
$('#MyForm').show();

 

3 Comments

Sort by Best Controversial New
 
2

Thank you for this tip! Definitely helped me implementing it.

admin · 5 years ago
permalink · reply (0)
0

Is CKEditor better than TinyMCE?

Joomla · 5 years ago
permalink · reply (1)
0

@Joomla: I tried TinyMCE... I think it's to combuluted. I am currently using Markdown. But I'm thinking of switching to a Wysiwyg since my users find it complicated.

master_yii · 5 years ago
permalink · reply



Our Terms of Use and Privacy Policy have changed.
By continuing to use this site, you are agreeing to the new Privacy Policy and Terms of Use.