KindEditor得不到textarea值的解决方法

admin6年前IT技术1685

 

  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();

相关文章

在Hyper-V 虚拟机环境设置centos 7固定IP

在Hyper-V 虚拟机环境设置centos 7固定IP

Hyper-V 管理器的自动停止操作的选项里,设置"保持虚拟机状态"如下图所示:...

汇成游戏发布网站系统v1.1

汇成游戏发布网站系统v1.1˂a href="shengji/gamefbv11.rar" target="_blank"˃官方下载在空余时间开发了一套简单,体积很小的游戏发布网站,由于时间仓促,可能...

windows下安装、卸载mysql服务

windows下安装、卸载mysql服务2012年03月09日 16:30:20阅读数:52062 将下载下来的mysql解压到指定目录下(如:d:\mysql)安装服务 在命令行输入d:\...

解决方案2
打开的本地组策略

Win10远程连接的凭据不工作的解决方法

 把远程桌面工具的本地资源的打印机与剪贴板的勾勾取消解决方案2打开的本地组策略在右侧打开的窗口中双击“网络访问:本地账户的共享和安全模型”一项在打开的属性窗口中,我们...

php上传路径问题

php图片上传不认"\"C:\Users\Administrator\Desktop\"只认C:/Users/Administrator\Desktop/...

mount:is write-protected, mounting read-only解决方案

window10升级之后就遇到mount: **** is write-protected, mounting read-onlymount: cannot mount *** read-only尝试...

发表评论    

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