KindEditor富文本编辑器的使用

一.初始化 kindeditor 编辑器
在页面中添加 JS 代码,用于初始化 kindeditor

allowFileManager 【是否允许浏览服务器已上传文件】 默认值是:false

<	script	 type="text/javascript"> 
		var editor; 
 	KindEditor.ready(function(K) { 
 	 	editor = K.create('textarea[name="content"]', { 
 	 	 	allowFileManager : true 
 	 	}); 
 	}); 

二.提取 kindeditor 编辑器的内容

给商品介绍属性添加上富文本输入的值

$scope.entity.goodsDesc.introduction=editor.html(); 

三.清空 kindeditor 编辑器的内容
添加完成后对编辑表单和富文本框进行清空

function(response){ 
 	 	if(response.success){ 
 	 	 	alert("保存成功");  	 	 	
 	 	 	$scope.entity={}; 
 	 	 	editor.html('');//清空富文本编辑器 
 	 	}else{ 
 	 	 	alert(response.message); 
 	 	} 
}  

页面代码如下:





    
    
    
    商品编辑
    
    
  
    
    
    
    
	
    
    
    
	
	 
		
	
	
	
    
    
    
    
	
	
	
    
    
      
    
    




            
            

保存方法`
$scope.entity={tbGoods:{},tbGoodsDesc:{},tbItems:[]};

// 保存
$scope.add = function() {
	
	  //将富文本编辑器中输入的内容保存到组合对象中商品介绍属性中
	$scope.entity.tbGoodsDesc.introduction=editor.html();
	
	 goodsService.add($scope.entity).success(function(response) {
		if (response.success) {
			
			alert(response.message);
			//添加成功后将编辑表格和富文本框进行清空
			$scope.entity={};
			editor.html("");
		} else {
			alert(response.message);
		}
	});
}`

你可能感兴趣的:(笔记,java)