KindEditor得不到textarea值的解决方法

admin5年前IT技术1366

 

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

相关文章

windows 激活

windows 激活

Win7查看系统信息:slmgr.vbs -xpr         键入:slmgr.vbs -ipk FJ82H-XT...

adobe验证屏蔽

127.0.0.1 lmlicenses.wip4.adobe.com  127.0.0.1 lm.licenses.adobe.com  127.0.0.1...

magento性能优化的教程

Magento是一套专业开源的电子商务系统,Magento设计得非常灵活,具有模块化架构体系和丰富的功能但有朋友会发现此模块用到了会发现非常的缓慢了,那么下面我们来看关于magento性能优化的例子。...

shadowsocks_install

执行命令:bash <(curl -sL https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadow...

美国年轻人都在玩哪些App[转]

美国年轻人都在玩哪些App[转]

Facebook 它对我们这个年龄的人来说已经死了,Facebook 是我们中学时候玩儿的,但是现在就像尴尬的家庭晚宴一样鸡肋,你会经常遇到这个问题:「别人都用 Facebook,你怎么不用?」(貌似...

L2TP端口

1701,1702,4500,500...

发表评论    

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