KindEditor得不到textarea值的解决方法

admin6年前IT技术1489

 

  1. 下面以 KindEditor 4.x 版本为例说明,先贴上正确的代码:

     

     

     

     

     

     

     

     

     

    <script type="text/javascript">

    //天涯PHP博客 http://blog.phpha.com

    KindEditor.ready(function(K){

    K.create('textarea[name="content"]', {

    themeType: 'simple',

    resizeType: 1,

    uploadJson: 'common/KEditor/upload_json.php',

    fileManagerJson: 'common/KEditor/file_manager_json.php',

    allowFileManager: true,

    //经测试,下面这行代码可有可无,不影响获取textarea的值

    //afterCreate: function(){this.sync();}

    //下面这行代码就是关键的所在,当失去焦点时执行 this.sync();

    afterBlur: function(){this.sync();}

    });

    });

    </script>

    相关说明:从上面的代码可以看到,解决方法在于最后一行代码,afterBlur: function(){this.sync();},当失去焦点时执行 this.sync();那么这个 this.sync(); 函数是干嘛的呢?简单的说:这个函数就是同步KindEditor的值到textarea文本框

  2. 2

    官方解释://天涯PHP博客 http://blog.phpha.comsync()将编辑器的内容设置到原来的textarea控件里。参数: 无返回: KEditor地址:http://www.kindsoft.net/docs/editor.html#sync

    补充:在 KindEditor 4.x 版本中,KE.sync(); 要改成 this.sync();

相关文章

dell G15游侠重装系统

https://www.dell.com/support/kbdoc/zh-cn/000176966/%E5%A6%82%E4%BD%95%E5%9C%A8%E6%88%B4%E5%B0%94%E8%...

二维码生成导航

http://twoyn.shengmake.nethttp://twalabo.shengmake.nethttp://twyilang.shengmake.nethttp://twyindu.sh...

php正则提取中文

<?php$str = "用户名123阿斯蒂芬dfsdf阿道夫";//把结果放在$chinese中//GBK/GB2312使用:preg_match_all("/[...

linux 挂载win7共享文件夹的方法

mount -t cifs -o user=administrator,password=000000 //192.168.1.2/gongxiang /mnt/share...

服务器2012打开远程端口,Windows Server 2012远程默认端口3389的修改

服务器2012打开远程端口,Windows Server 2012远程默认端口3389的修改

Window Server2012 修改远程桌面端口号Win + R 输入 regedit 打开注册表编辑器1、修改注册表项1HKEY_LOCAL_MACHINE/System/CurrentCont...

ASP中Connection对像封装dll解决方案

asp代码保密一直是令人头痛的问题,目前没有非常好的解决方案,无非用vb编译成dll,但工作量实在太大,于是一直苦苦寻求着另一种途径。。。  中午,突然灵感一发,“为什么不尝试用加密数据库...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。