1.官网down KindEditor,添加到自己的项目中;添加时可把不需要的文件夹干掉,asp/php等等。我的项目用的是纯html和js,直接调用后台api;

2.页面引入相关js。eclipse中打开min.js的时候可能会报错,直接忽略就可以,不影响使用。

<link rel="stylesheet" href="/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="/kindeditor/plugins/code/prettify.css" />
<script charset="utf-8" src="/kindeditor/kindeditor-all-min.js"></script>
<script charset="utf-8" src="/kindeditor/lang/zh-CN.js"></script>
<script charset="utf-8" src="/kindeditor/plugins/code/prettify.js"></script>

3.编辑器初始化脚本。

<script type="text/javascript">
KindEditor.ready(function(K){
K.create('textarea[name="messagecontent"]', {
themeType: 'simple',
resizeType: 1,
allowFileManager: true,
//当失去焦点时执行 this.sync();
afterBlur: function(){this.sync();}
});
});
</script>

4.form表单添加文本域。

<textarea id="editor" name="messagecontent" style="width:700px;height:300px;"></textarea>

5.表单提交,如果不执行sync()函数,将无法获取到textarea的值。

function saveMsgInfo(){
if($('#msgInfoForm').form('validate')){
var formData = $("#msgInfoForm").serialize();
formData = decodeURIComponent(formData,true);
console.info(formData);
$("#msgInfoForm").form("submit", {
url:forceRefresh('msg/info/createMsgInfo'),
onSubmit: function(param){
param = formData;
},
success: function(data){ }
});
}
}

6.文本域的清空和赋值

KindEditor.instances[0].html("");
KindEditor.instances[0].html(val);

最新文章

  1. Lesson 13 The Greenwood Boys
  2. 使用Word发布文章到 WordPress 博客
  3. 一台MySQL服务器启动多个端口
  4. Android笔记:限定符
  5. Ieditor
  6. android依赖工程,子工程覆盖父工程的相同属性
  7. c#中执行多条sql语句【ORA-00911: 无效字符】
  8. Oracle 基础——索引
  9. MVC系统过滤器、自定义过滤器
  10. 搭建solr单机版
  11. 【转】GLONASS全球卫星导航系统
  12. c# cbo控件
  13. Java对数
  14. axios 使用post方式传递参数,后端接受不到
  15. GDB &amp;&amp; QString
  16. python学习笔记_week12_mysql
  17. Codeforces Round #368 (Div. 2) A. Brain&#39;s Photos 水题
  18. An internal error occurred during: &amp;quot;Building workspace&amp;quot;. GC overhead limit exceeded
  19. eclipse下编译cocos2dx 3.0
  20. C++和Python混合编程

热门文章

  1. Hackrank Equal DP
  2. myeclipse.hbm.xml自动生成
  3. 1分钟看完 jQuery UI
  4. Chart.js docs
  5. 并不对劲的bzoj5020:loj2289:p4546:[THUWC2017]在美妙的数学王国中畅游
  6. python-----贴图 和 报错:OSError: image file is truncated (8 bytes not processed)的处理
  7. Python sklearn Adaboost
  8. Bootstrap 面板
  9. bzoj 1502 月下柠檬树【Simpson积分】
  10. UVA1437 String painter