I have a Content Management System where I'm using CKEditor to edit content loaded from a hidden form field on the page. When you click an edit button, CKEditor appears in a lightbox with the content inside. I'm using CKEditor 3.3, Lightbox_Me (http://buckwilson.me/lightboxme/), and jQuery 1.4.2
The code mostly works fine, however when I open the lightbox and then close it again quickly, I get a Javascript error "s.document.getWindow().$ is undefined" I assume this is because CKEditor isn't loading entirely and then its elements get destroyed before it can finish.
Is there any way to prevent this, other than somehow not allowing people to close the editor until after it's totally loaded?
Here's my code
var coverageAreaDescription = $(this).siblings('.coverageAreaDescriptionSave').val();
$('body').append('<div id="coverageAreaDescriptionLightbox"><textarea id="coverageAreaDescriptionEditor">' + coverageAreaDescription + '</textarea></div>');
if (CKEDITOR.instances['coverageAreaDescriptionEditor']) {
CKEDITOR.remove(CKEDITOR.instances['coverageAreaDescriptionEditor']);
}
CKEDITOR.replace('coverageAreaDescriptionEditor');
$('div#coverageAreaDescriptionLightbox').lightbox_me({
centered: true,
destroyOnClose: true,
closeEsc: true,
closeSelector: "button#closePreview",
onLoad: function() {
},
onClose: function() {
}
});