Reputation: 619
I installed CKeditor for Yii2 according to extension docs.
I have pages in rendered in controller for eg.:
public function actionTest($id)
{
$model = $this->findModel($id);
return $this->renderAjax('/test', ['model' => $model]);
}
CKeditor loads properly if it is via:
return $this->render('/test', ['model' => $model]);
but does not load if it is loaded via renderAjax()
. Seems to be CKeditor's jquery missing in this content. May I know how to add it to this page?
In my view:
<?= $form->field($model, 'Desc')->label('Description'. Html::tag('span', '*',['class'=>'required']))->widget(CKEditor::className(), [
'options' => ['rows' => 6],
'preset' => 'basic'
])
?>
Upvotes: 0
Views: 589
Reputation: 33538
In case of dynamically loaded textarea you need to reinitialize CKEditor in AJAX success callback.
It can be done like so:
CKEDITOR.replace('id-of-your-textarea-field');
Links:
Upvotes: 1