zoukankan      html  css  js  c++  java
  • KindEditor得不到textarea值的解决方法

    以前有朋友遇到过这个问题,就是KindEditor在火狐下或者其他浏览器下都无法得到textarea文本框的值,点击表单提交按钮得到的是空白。昨天天涯PHP博客[http://blog.phpha.com]也无意遇到这个问题,于是想认真找下原因。
    首先描述下我这边KindEditor的错误现象:
    1、在IE8/FF下均得不到值;
    2、当点击KindEditor的全拼按钮切换到全屏模式输入时,再返回正常模式,可以得到值;
    3、我用的是jQuery的点击事件提交表单的,提交,无法得到值;
    4、直接用表单的提交按钮可以得到值。

    下面以 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>
    
  • 相关阅读:
    centos 7 安装maven
    linux添加用户
    intellij添加jar包
    mysql用户管理
    centos7 mariaDB安装
    hibernate入门实例
    Linux文件描述符
    Python小爬虫实例
    IO流-文件管理
    IO流-ZIP文档
  • 原文地址:https://www.cnblogs.com/onesmail/p/5362397.html
Copyright © 2011-2022 走看看