KindEditor得不到textarea值的解决方法

admin6年前IT技术1621

 

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

相关文章

apache配置SSL以及同一站点多端口配置

 <VirtualHost *:443>  ServerName www.ilikegoodproducts.com DocumentRoot &q...

通过IP获取MAC地址

关键知识点:ARP缓存时间是十分钟;实现的命令是:第一步  ping  ip第二部  arp -a基础解释:在底层的网络通信中,两个节点想要相互通信,必须先要知道源与目标...

二维码生成导航

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

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

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

【AFFILIATE】值得新手加入的联盟营销平台

【AFFILIATE】值得新手加入的联盟营销平台

 如果你也希望自己的博客能成为money machine,为你打工赚钱,那联盟营销或许是一个非常好的选择,好消息是,有很多非常可靠的联盟营销平台敞开大门欢迎大家的加盟,不关你是新博主还是已经...

excel 批量粘贴图片的方法

1.e2是图片地址在表格下拉,批量输入="<table><img src="&e2&" height=100&nbs...

发表评论    

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