yii怎么整合 ckeditor [ 新手入门 ]
是最新版的 ckeditor3.6.1 不是fckeditor 我整了半天 只整合了 fckeditor2.6.6的 fckeditor2.6.6对ie9兼容不好?不好使[attach]283[/attach]
共 2 条回复
-
-
asset/CkeditorAsset
<?php
namespace common\assets;use yii\web\AssetBundle;
/*- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
and open the template in the editor.
*/
class CkeditorAsset extends AssetBundle
{
public $sourcePath = '@vendor/almasaeed2010/adminlte/plugins/ckeditor';public $js = [
'ckeditor.js',
];
public $css = [
];public $depends = [
'\dmstr\web\AdminLteAsset'
];
}
视图中引用js
<?phpuse yii\helpers\Html;
use yii\widgets\ActiveForm;
use dosamigos\datepicker\DatePicker;common\assets\CkeditorAsset::register($this);
<?php $form = ActiveForm::begin(); ?> <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'keywords')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'typeId')->dropDownList(\yii\helpers\ArrayHelper::map($configModel['NewsType'],'id','name')); ?> <?= $form->field($model, 'seen')->textInput(['value' => '0']) ?> <?= $form->field($model, 'createTime')->textInput(['id' => 'datepicker'])?> <?= $form->field($model, 'isHot')->textInput(['value' => '0']) ?> <?= $form->field($model, 'isTop')->textInput(['value' => '0']) ?> <?= $form->field($model, 'sort')->textInput(['value' => '0']) ?> <?= $form->field($model, 'status')->textInput(['value' => '0']) ?> <?= $form->field($model, 'content')->textarea(['id' => 'editor1']) ?> <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> <?php ActiveForm::end(); ?>
$this->registerJsFile('/js/news.js',['depends'=>'common\assets\DatePickerAsset']);
$this->registerJsFile('/js/news-editor.js',['depends'=>'common\assets\DatePickerAsset']);
/ @var $this yii\web\View /
/ @var $model backend\models\News /
/ @var $form yii\widgets\ActiveForm /
?>web/js
$(function () {// Replace the <textarea id="editor1"> with a CKEditor // instance, using default configuration. CKEDITOR.replace('editor1');
});
fiaw
最后登录:1970-01-01
在线时长:0小时0分
- 粉丝0
- 金钱215
- 威望0
- 积分215