CKEditor + Yii loaded by AJAX: $ _POST does not contain updated value

:

  • I am using Yii Framework

  • I have one Ckeditor window on my page (php / yii framework - works great)

  • when I click the button, a new CKeditor window is created and displayed through an AJAX call

  • PROBLEM: This new CKEditor window correctly displays text stored in the database. BUT: when I click "Save" (the ajax button generated along with the rest of the form), the values ​​from this new window will not be saved by CKeditor: CKeditor sends back the old values ​​received from the database.

When I remove Ckeditor and leave it simple <textarea>: everything is fine, so I know that the controller is fine.

Please, did anyone go through something like this?

+3
source share
2 answers

Sounds like a typical JAJAJAX binding problem. :) There are several options to fix this, depending on what is going wrong.

This post on the Yii forum should be for you money, where I received most of these offers: http://www.yiiframework.com/forum/index.php?/topic/9341-ckeditor-widget-in-a-cactiveform/

  • Use the Yii widget extension that already solved this problem ( NHCKEditor? )
  • Add the onClick callback to the submit button, which keeps the contents of CKEditor hidden 'textarea' ('onclick'=>'CKEDITOR.instances.TEXTAREA_ID.updateElement()',
  • Use jQuery to get data from CKEditor iFrame to use ... everywhere. AJAX validation etc.

Good luck

+1
source

CKEDITOR , clientside/ajax , :

<?php $form = $this->beginWidget('CActiveForm', array(
    'enableAjaxValidation' => true,   // one or both
    'enableClientValidation' => true, // one or both
    'clientOptions' => array(
        'validateOnSubmit' => true,   // optional
        'beforeValidate' => new CJavaScriptExpression('function(form) {
            for(var instanceName in CKEDITOR.instances) { 
                CKEDITOR.instances[instanceName].updateElement();
            }
            return true;
        }'),
    ),
)); ?>
+1

All Articles