富文本KindEditor使用
2024-08-30 18:41:17
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);
最新文章
- Lesson 13 The Greenwood Boys
- 使用Word发布文章到 WordPress 博客
- 一台MySQL服务器启动多个端口
- Android笔记:限定符
- Ieditor
- android依赖工程,子工程覆盖父工程的相同属性
- c#中执行多条sql语句【ORA-00911: 无效字符】
- Oracle 基础——索引
- MVC系统过滤器、自定义过滤器
- 搭建solr单机版
- 【转】GLONASS全球卫星导航系统
- c# cbo控件
- Java对数
- axios 使用post方式传递参数,后端接受不到
- GDB &;&; QString
- python学习笔记_week12_mysql
- Codeforces Round #368 (Div. 2) A. Brain&#39;s Photos 水题
- An internal error occurred during: &;quot;Building workspace&;quot;. GC overhead limit exceeded
- eclipse下编译cocos2dx 3.0
- C++和Python混合编程
热门文章
- Hackrank Equal DP
- myeclipse.hbm.xml自动生成
- 1分钟看完 jQuery UI
- Chart.js docs
- 并不对劲的bzoj5020:loj2289:p4546:[THUWC2017]在美妙的数学王国中畅游
- python-----贴图 和 报错:OSError: image file is truncated (8 bytes not processed)的处理
- Python sklearn Adaboost
- Bootstrap 面板
- bzoj 1502 月下柠檬树【Simpson积分】
- UVA1437 String painter