优先依辅kindeditor-min.js插件 JQ的sleep在底部
<script>
var editor;
KindEditor.ready(function (K) {
editor = K.create('textarea[id="comm_desc"]', {
allowFileManager: true,
autoHeightEnabled: true,
autoFloatEnabled: true,
width: 800,
height: 300,
indentValue: '2em',
allHtmlEnabled: true,
// imageUploadJson: '/saveImg',
uploadJson: '/Uploadfile/kindFile/',
afterChange: function () {
$("#comm_desc").html(this.count('text'));
}
});
});
</script>
HTML代码处理 赋值直接给过去
<textarea id="comm_desc" name="comm_desc" rows="5" style="width: 80%;"><{$jxsInfo.comm_desc}></textarea>
提交的是时候注意
<script>
var comm_descs = editor.html();
var comm_descs = comm_descs.replace(/(\n)/g, "");
//直接ajax data带参数走人
</script>
提交编辑器里对应图片啥文件
//KindEditor 编辑器上传文件
public function kindFileAction(){
$this->upconfig['savePath'] = 'attached/';
$up_ins = Comm_Uploadimg::getInstance($this->upconfig);
$res = $up_ins->uploadOne($_FILES['imgFile']);
if($res){
$imgpath = $this->upconfig['rootPath'] . $res['savepath'] . $res['savename'];
$img_ins = Comm_Image::getInstance();
if(in_array($res['ext'],$img_ins->compress_type)){
$img_ins->open($imgpath)->compress()->save($imgpath);//压缩处理;
}
$info = substr($imgpath, 1);
$response = array('error' => 0, 'url' => $info);
}else{
$response = array('error' => 1, 'message' => $up_ins->getError());
}
exit(json_encode($response));
}
最后两个结尾处理,第一个是ajax获得对应编辑器数据 动态赋值
//如果不为空 进行处理 否则编辑器出现 null数据
if(dataInfo.comm_desc != 'null' && dataInfo.comm_desc ){
editor.html(dataInfo.comm_desc);
}else{
editor.html('');
}
第二个JQ的sleep 只说一种
如果弹层提示消失或者显示后在操作 在里边回调 2000等于2秒
$("#test").delay(2000).hide(function(){}); //传回调函数或
$("#test").delay(2000).hide(1); //动画的速度 或 fast 或 slow 或 随便写如 xxx