KindEditor得不到textarea值的解决方法

admin5年前IT技术1292

 

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

相关文章

关于jquery升级至1.8版本之后的兼容问题Uncaught TypeError: $(...).size is not a function

关于jquery升级至1.8版本之后的兼容问题Uncaught TypeError: $(...).size is not a function

之前也遇到过这种问题Uncaught TypeError: $(...).size is not a function  控制台报错如上图,打开Frame.js可以看到里面定义大小...

信息

支付宝:帐号:zhoukouhu@126.com户名: 周扣虎支付宝收款主页:https://me.alipay.com/huicheng 招商银行帐号:6225 8821 1195 501...

汇成电动工具行业企业网站系统v12.1

汇成电动工具行业企业网站系统v12.1˂a target="_blank" href="download/jixie/jixieddgjv121.rar"˃官方下载汇成企业网站管理系统为中小企业免费建...

vb设置全屏与设置退出--快捷键

退出VB   unload meVB全屏:Form1.Left = 0Form1.Top = 0Form1.Width = Screen.WidthForm1.Height = S...

小米手机安装google play store的方法

MIUI的版本必须在>=12.5.9之上没有就必须升级打开账号与同步然后打开谷歌服务就ok了...

Docker安装

sudo yum install -y yum-utils二选一yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/li...

发表评论    

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