I have a fairly basic form that is being shown in a Ctools modal. It has a "text_format" field to which a Ckeditor is being attached. Upon loading the form everything works fine, but when validation fails the editor disappears (and the textarea has "visibility: hidden"). Firefox reports the following:
Error: uncaught exception: [CKEDITOR.editor] The instance "THE_TEXTAREA_ID" already exists.

Comments

Madis’s picture

I have little knowledge of Drupal behaviors, the Wysiwyg module and Ckeditor, but with a good amount of googling, checking the module code and trial - error I've managed to put together a workaround which in my current case solves the problem. It's a piece of javascript code I added in my custom module:

Drupal.behaviors.mymodule = {
	attach: function (context, settings) {
		// Check if there's errors in the modal.
		if ($('#modal-content .error').length > 0) {
                        // Check that the textarea and ckeditor exist.
			if ($('#THE_TEXTAREA_ID').length > 0 && typeof CKEDITOR != 'undefined') {
			    delete CKEDITOR.instances['THE_TEXTAREA_ID'];
			    Drupal.wysiwyg.editor.attach.ckeditor;
			}
		}
	}
};

Not sure how good or bad this workaround is, but might be of some use in helping to resolve the issue.

Madis’s picture

Category: bug » support
Priority: Normal » Minor
Status: Active » Closed (cannot reproduce)

Wasn't able to reproduce this on a clean install so it's likely a problem with my custom code somewhere.