Hello,

In a configuration with the modules 'maxlength' and 'ckeditor' installed, and in an node edit page without a ckeditor, I get a JS error: 'CKEDITOR not defined' because of the following code:

  ml.ckeditor = function() {
    // We only run it once
    var onlyOnce = false;
    if (!onlyOnce) {
      onlyOnce = true;
      CKEDITOR.on('instanceReady', function(e) {

which is called on the condition:

      } else if (Drupal.settings.ckeditor != undefined) {

which checks that the module 'ckeditor' is installed, but not that ckeditor is actually initialized on the page.

The patch to fix this will follow.

Comments

ndeschildre’s picture

Status: Active » Needs review
StatusFileSize
new381 bytes

Please find attached the patch.

--- a/js/maxlength.js
+++ b/js/maxlength.js
@@ -13,7 +13,7 @@
             ml[editor]();
           }
         });
-      } else if (Drupal.settings.ckeditor != undefined) {
+      } else if (Drupal.settings.ckeditor != undefined && typeof(CKEDITOR) !== 'undefined') {
         ml.ckeditor();
       }
rooby’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

This also happens on my site.

It is more of an issue because it breaks other javascript on the page and things don't work properly.

The patch fixes it for me and looks good so setting RTBC to maybe get someone else's eyes on it.

mvwensen’s picture

Fix also works on 7.x-3.0-beta1 after changing (manually)

dawehner’s picture

What about adding a small comment why we are doing that here? Just as a random guy i wouldn't know what is going on :)

drclaw’s picture

This patch also worked for me (manually applied). Thanks!

To help other people searching this issue: I needed this because the maxlength was giving an error Uncaught ReferenceError: CKEDITOR is not defined. This was because even though I had CKEDITOR installed, it wasn't being used on my field which was using the "Plain Text" text format.

Anonymous’s picture

Patch worked for me. Please include in the module soon :)

dasjo’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work

this needs a re-roll

dasjo’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new381 bytes

this one applies to the latest dev

frjo’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

This fix is already committed to 7-dev and are part of 7.x-3.0.