Context
CKEditor is a rich text editor that uses an iframe with an editable body.
I have a situation where I need to temporarily remove an element containing a CKEditor instance from my page, then add it back some arbitrary amount of time later.
Problem
Unfortunately, this seems to cause the iframe to reset. Where the editor originally contained the rich text content and an editable body element, after adding the editor back to the page the iframe body is empty and no longer editable.
Question
I'm hoping someone can explain why this is happening and how I can reinitialize the CKEditor once I've added it back to the DOM. I've searched the documentation and have yet to find an answer.
Destroying the instance and re-creating is possible, but it's going to require some significant changes to our architecture. I'd rather avoid that, if possible. (Though "there's no other option" is an acceptable answer, if true.)
Example
Here's an extremely simplified version of my code which recreates the issue:
CKEDITOR.replace('text');
var wrapper = $("#wrapper"),
parent = $("#parent");
// Immediately after creating the CKEditor instance,
// it is possible to remove and append the editor
hideshow();
// Remove and append some moments after the page load causes
// the content of the CKEditor to be lost (and not editable)
$('#hideshow').click(hideshow);
// (I'm guessing this is because the click event happens
// sometime after the editor is initialized.)
function hideshow(){
wrapper.remove();
parent.append(wrapper);
}
http://jsfiddle.net/cyborgx37/f496p7us/
What can I add to the hideshow
function above to restore the content of my editor?