不依靠框架文本编辑器,以及JQ的sleep问题

优先依辅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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值