我在我的表单中使用 TinyMCE。一切都完美发布,直到我启用 ajax。单击“保存”时,文本区域“内容”为空,但如果我禁用 TinyMCE,则 ajax 帖子显示没有问题。有任何想法吗?
这是我调用 TinyMCE 的代码:
$tiny = new TinyMce();
$tiny->buildTinyMce("textarea");
TinyMCE 寄存器功能:
public function buildTinyMce($selector="textarea"){
$file = $this->getTinyMce().'/tinymce.min.js';
$script = '
tinymce.init({
selector: "'.$selector.'",
theme: "modern",
plugins: [
"advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
"save table contextmenu directionality emoticons template paste textcolor responsivefilemanager"
],
toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent",
toolbar2: "| link unlink | image media | responsivefilemanager",
external_filemanager_path:"/filemanager/",
filemanager_title:"Media Manager",
external_plugins: { "filemanager" : "/filemanager/plugin.min.js"}
});
';
Yii::app()->clientScript->registerScriptFile($file);
Yii::app()->clientScript->registerScript("1",$script,CClientScript::POS_HEAD);
}
最后是我的表格
<div class="row">
<?php echo $form->labelEx($model,'content');?>
<?php echo $form->textArea($model,'content');?>
<?php echo $form->error($model,'content');?>
</div>
<?php echo $form->error($model,'type');?>
</div>
<div class="row buttons">
<?php echo CHtml::ajaxSubmitButton($model->isNewRecord ? 'Save' : 'Update',
Yii::app()->createUrl('lesson/create'), array( 'dataType' => 'html', 'type' => 'post', 'update' => '.err-msg')
); ?>
</div>
<?php $this->endWidget(); ?>
<div class="err-msg"></div>