KindEditor得不到textarea值的解决方法

admin6年前IT技术1427

 

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

相关文章

汇成税务部门建站CMS系统V1.0

汇成税务部门建站CMS系统V1.0˂a href="download/hcshuiwuv1.0.rar" target="_blank"˃官方下载后台地址:您的地址/admin/login.asp帐号...

excel参照另一列筛选数据的函数

=IF(ISERROR(VLOOKUP(D7,F:F,1,0)),D7,1) ISERROR防止报错 ...

ubuntu 远程连接 22 端口

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

magento2.3.5 安装与优化过程

 bin/magento setup:install --base-url=https://www.mytinely.com/ \--db-host=localhost --db-name=...

Float引起div自适应高度解决办法。

Float引起div自适应高度解决办法。方法一:如果父元素没有设置高度,那么我们可以在父元素中添加:“overflow:hidden;”来清除浮动,即可通过浮动元素撑开父元素。...

解决Cannot load php7apache2_4.dll into server导致无法启动Apache

萌新在面对服务端开发使用PHP搭配Apache时会遇见Cannot load php7apache2_4.dll into server 例如 01 最最最主要的问题 Apache...

发表评论    

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