KindEditor得不到textarea值的解决方法

admin6年前IT技术1623

 

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

相关文章

magento1.x开启调试模式

magento1.x开启调试模式

方法一设置:Current Configuration Scope: main website 通过后台控制台来操作,admin->configuration->develope...

Centos7系统pip的安装

介绍pippip 是一个Python包安装与管理工具。yum方式安装pipyum install python-pip -y升级pippip install&n...

centos共享远程目录

服务器端设置:1.安装依赖包 yum -y install nfs*2.修改文件vim /etc/exports   添加如下内容    /要共享的目...

win10卸载服务 在Windows 10系统

在Windows 10系统中卸载服务可以通过以下步骤进行:打开运行窗口。按下Win键+R键,输入“services.msc”后回车,打开服务列表。1在服务列表中,找到需要卸载的服务。服务名称和显示名...

magento2.x系统加速

magento2.x系统加速

1:在根目录运行以下命令,全站生成静态bin/magento setup:static-content:deploy2:编译整个网站,让网站加速50%  注意事项:要把PHP脚本内存限制设置...

ubuntu 远程连接 22 端口

安装OpenSSHUbuntu缺省没有安装SSH Server,使用以下命令安装:sudo apt-get install openssh-server openssh-client不过Ubuntu缺...

发表评论    

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