不依靠框架文本編輯器,以及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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章