写在前面

  上一篇《初试JqueryEasyUI(附Demo)》;

  在上一篇说过,下面要试下easyui集合编辑器,关于编辑器网上有很多,ckeditor、ueditor、kindeditor、eWebEditor等,其实最早接触的是ckeditor(fckeditor),用着功能确实不错,但是感觉太复杂了,而且东西也比较大,不是很方便,ueditor是百度出品的,但是用过kindeditor之后发现感觉还是kindeditor比较好用点,个人感觉,勿喷!

  kindeditor的示例也是比较全的,而且兼容性也比较好,就用它试着集合easyui了。

实现

  因本人js技术有限,试了好久也没搞好,此处略去十万个字。。。

  网上找到一段js代码:

 (function ($, K) {
if (!K)
throw "KindEditor未定义!"; function create(target) {
var opts = $.data(target, 'kindeditor').options;
var editor = K.create(target, opts);
$.data(target, 'kindeditor').options.editor = editor;
} $.fn.kindeditor = function (options, param) {
if (typeof options == 'string') {
var method = $.fn.kindeditor.methods[options];
if (method) {
return method(this, param);
}
}
options = options || {};
return this.each(function () {
var state = $.data(this, 'kindeditor');
if (state) {
$.extend(state.options, options);
} else {
state = $.data(this, 'kindeditor', {
options : $.extend({}, $.fn.kindeditor.defaults, $.fn.kindeditor.parseOptions(this), options)
});
}
create(this);
});
} $.fn.kindeditor.parseOptions = function (target) {
return $.extend({}, $.parser.parseOptions(target, []));
}; $.fn.kindeditor.methods = {
editor : function (jq) {
return $.data(jq[0], 'kindeditor').options.editor;
}
}; $.fn.kindeditor.defaults = {
resizeType : 1,
allowPreviewEmoticons : false,
allowImageUpload : false,
items : [
'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
'insertunorderedlist', '|', 'emoticons', 'image', 'link'],
afterChange:function(){
this.sync();
}
};
$.parser.plugins.push("kindeditor");
})(jQuery, KindEditor);

  需要同时引用easyui和kindeditor相关样式和脚本,然后就可以像使用easyui组件一样使用kindeditor:

   <textarea name="easyui_ditor" id="easyui_ditor" class="easyui-kindeditor" style="width: 100%; height: 200px; visibility: hidden;">EasyUI集合KindEditor</textarea>

  如果你使用的是后台获取设置kindeditor值的话可以使用这个,但是js获取或设置文本框值,上面就不好实现,也试了很多方法没有解决,有关js的大神如果知道方法还请赐教。

  注意创建kindeditor的时候有个afterChange事件,表示更改编辑器的内容发生的事件,这边需要重写下。其实kindeditor不集合到easyui中也是可以使用,只不过没有上面这样创建方便,做了个示例,大家可以看下:

                 <tr>
<td>easyui-kindeditor编辑器:</td>
<td>
<textarea name="easyui_ditor" id="easyui_ditor" class="easyui-kindeditor" style="width: 100%; height: 200px; visibility: hidden;">EasyUI集合KindEditor</textarea>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="">设置</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="alert(KindEditor.html())">获取</a>
</td>
</tr>
<tr>
<td>kindeditor编辑器:</td>
<td>
<textarea name="txtContent" id="txtContent" style="width: 100%; height: 200px; visibility: hidden;">KindEditor</textarea>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="editor.html('我在设置KindEditor内容');">设置</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="alert(editor.html())">获取</a>
</td>
</tr>

  js代码:

         //编辑器
var editor;
KindEditor.ready(function (K) {
editor = K.create('textarea[name="txtContent"]', {
allowFileManager: true,
resizeType: 1,
allowPreviewEmoticons: false,
items: [
'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
'insertunorderedlist', '|', 'emoticons', 'image', 'link']
});
});

  效果:

  完整示例Demo下载:http://pan.baidu.com/s/1c0zP6KC

关于JqueryEasyUI集合Kindeditor的更多相关文章

  1. (编辑器)Jquery-EasyUI集合Kindeditor编辑器

    1.在html里面添加 list.html list.html (function ($, K) { if (!K) throw "KindEditor未定义!"; functio ...

  2. 最近遇到的若干Web前端问题:disable和readonly,JqueryEasyUI,KindEditor

    最近项目中用到了Jquery Easyui和KindEditor等框架组件,问题真不少啊~  一些看起来很简单理所当然的事情,竟然花费了不少时间,才解决好~  1.readonly和disable的区 ...

  3. jQueryEasyUI

    jQueryEasyUI 编辑 jQuery EasyUI是一组基于jQuery的UI插件集合体,而jQuery EasyUI的目标就是帮助web开发者更轻松的打造出功能丰富并且美观的UI界面.开发者 ...

  4. 二十二、【轻量级开源框架】EFW框架Web前端开发之JqueryEasyUI

    回<[开源]EFW框架系列文章索引>        EFW框架源代码下载V1.2:http://pan.baidu.com/s/1hcnuA EFW框架实例源代码下载:http://pan ...

  5. JqueryEasyUI教程入门篇

    什么是jQueryEasyUI? JqueryUI是一组基于jQuery的UI插件集合 学习jQueryEasyUI的条件? 必须掌握Jquery的基本语法知识 jQueryEasyUI的特点? 1. ...

  6. [转]JqueryEasyUI教程入门篇

    什么是jQueryEasyUI? JqueryUI是一组基于jQuery的UI插件集合 学习jQueryEasyUI的条件? 必须掌握Jquery的基本语法知识 jQueryEasyUI的特点? 1. ...

  7. jquery-easyui实现页面布局和增删改查操作(SSH2框架支持)转载

    http://blessht.iteye.com/blog/1069749/ 已注册:ooip 关联的csdn 前几天心血来潮用jquery-easyui+spring.struts2.hiberna ...

  8. “MVC+Nhibernate+Jquery-EasyUI” 信息发布系统 第四篇(用户管理功能的实现)

    “MVC+Nhibernate+Jquery-EasyUI” 信息发布系统 第四篇(用户管理功能的实现) 一.前三篇的内容是否对您有帮助呢?如果有的话,请您继续关注这篇吧,这篇主要是实现”用户管理“的 ...

  9. python学习博客地址集合。。。

    python学习博客地址集合...   老师讲课博客目录 http://www.bootcdn.cn/bootstrap/  bootstrap cdn在线地址 http://www.cnblogs. ...

随机推荐

  1. Torch7学习笔记(二)nn Package

    神经网络Package [目前还属于草稿版,等我整个学习玩以后会重新整理] 模块Module module定义了训练神经网络需要的所有基础方法,并且是可以序列化的抽象类. module有两种状态变量: ...

  2. K线图学习

    本博文(适合入门的股民朋友)内容来自网络,股市有风险,入市需谨慎 一.起源 K线图(Candlestick Charts)又称蜡烛图.日本线.阴阳线.棒线等,常用说法是“K线”,起源于日本十八世纪德川 ...

  3. 字符串转换为数字---使用java7的装箱功能

    以前转换只知道使用Xxx.prasexxx方法,原来,还可以直接装箱自动转换. //String类型字符串 String intStr = "123"; int str2int1 ...

  4. *HDU 1392 计算几何

    Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  5. Shell下突破安全狗远程桌面守护

    首先在Shell下把安全狗的安装配置给下来 默认安装路径: C:\Program Files\SafedogServer\SafeDogGuardCenter  找到 ProGuardData.ini ...

  6. 树莓派pppoe

    连接的网络是移动(铁通)的宽带,不同的宽带的dns需要修改. 1.首先安装pppoe包 apt-get install pppoe 2.然后,复制conf文件/etc/ppp/pppoe.conf: ...

  7. C语言的傻瓜式随笔(一):嵌套循环-程序结构

    循环语句的嵌套 一个循环结构内可以含有另一个循环,称为循环嵌套,又称多重循环.常用的循环嵌套是二重循环,外层循环称为外循环,内层循环称为内循环. ---------不知道哪来的基础概念 这是本宝宝的第 ...

  8. xcodebuild编译ipa

    #!/bin/sh # autoBuild.sh # CTest # # Created by Ethan on 14-11-3. # Copyright (c) 2014年 Ethan. All r ...

  9. Microservice 微服务的理论模型和现实路径

    两年前接触到了微服务的概念,面对日益膨胀的系统感觉豁然开朗.之后的两年逐步把系统按微服务的架构理念进行了重构,并将业务迁移到了新架构之上.感觉现在差不多是时候写一篇关于微服务的总结文章了. 定义 在 ...

  10. ABP理论学习之Web API控制器(新增)

    返回总目录 本篇目录 介绍 AbpApiController基类 本地化 审计日志 授权 工作单元 其他 介绍 ABP通过Abp.Web.ApiNuget包集成了 ASP.NET Web API控制器 ...