Hello,

Please consider the following scenario:
You enter a node edit form, with a text area with its text format select box. The default selected text format does not have ckeditor inserted. You thus enter in:

    Drupal.behaviors.ckeditor = {
        attach:
        function (context) {
[...]
          $(context).find("textarea.ckeditor-mod:not(.ckeditor-processed)").each(function () {
[..]
             $('#'+sel_format+':not(.ckeditor-processed)').addClass('').change(function(){

But no ckeditor was inserted, because of the text format configuration. So far, so good.

Now, you interact with a field widget that do AJAX interaction, e.g. filefield. The JS behaviors are called again. Since the ckeditor was not inserted, there is no "ckeditor-processed" class. And thus we reenter in the code quoted above, including the last line.
So

             $('#'+sel_format+':not(.ckeditor-processed)').addClass('').change(function(){

gets called twice, and two ckeditors will be inserted when I will choose another text format.

The patch will follow.

Nicolas

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ndeschildre’s picture

Here is the patch for 7.x-dev, tested on 7.x-1.8. Looks to be still valid for 7.x-dev. (and it is pretty trivial).

                 }

                 var sel_format = ta_id.substr(0, ta_id.lastIndexOf("-")) + "-format--2";
-                $('#'+sel_format).change(function(){
+                $('#'+sel_format+':not(.ckeditor-processed)').addClass('ckeditor-processed').change(function(){
                     Drupal.settings.ckeditor.elements[ta_id] = $(this).val();
                     if (CKEDITOR.instances && typeof(CKEDITOR.instances[ta_id]) != 'undefined') {
                         $('#'+ta_id).val(CKEDITOR.instances[ta_id].getData());
mkesicki’s picture

Status: Active » Needs review

@ndeschildre,
thank you for patch. We try check it as son as possible.

dczepierga’s picture

Status: Needs review » Fixed

@ndeschildre, really thx for your patch and review.
I make it in some other way and commit it to GIT (diff).

Pls update to last DEV version and if it doesn't help pls reopen this issue.

Greetings

dczepierga’s picture

Title: CKeditor gets inserted multiple times on text format selection » [D7] CKeditor gets inserted multiple times on text format selection
ndeschildre’s picture

Great, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mkesicki’s picture

Title: [D7] CKeditor gets inserted multiple times on text format selection » [D7] CKEditor gets inserted multiple times on text format selection