最近使用了版本为4.1.10的kindeditor文本编辑器,在保存数据的时候,在用火狐(IE)调试时无法得到textarea文本框的值,点击表单提交按钮得到的字段值是空字符。
经过上网查资料,分析原因如下:
4.0版本以后,需要添加如下一句代码 :
afterBlur: function(){this.sync();}
即当失去焦点时,这个函数就是同步KindEditor的值到textarea文本框。
<script src="../../Scripts/Jquery-1.8.0.min.js"></script>
<link href="../../Scripts/kindeditor/themes/default/default.css" rel="stylesheet" />
<link href="../../Scripts/kindeditor/themes/default/default.css" rel="stylesheet" type="text/css" />
<link href="../../Scripts/kindeditor/plugins/code/prettify.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/kindeditor/kindeditor.js" type="text/javascript"></script>
<script src="../../Scripts/kindeditor/lang/zh_CN.js" type="text/javascript"></script>
<script src="../../Scripts/kindeditor/plugins/code/prettify.js" type="text/javascript"></script>
<script type="text/javascript">
KindEditor.ready(function (K) {
var editor1 = K.create(‘#newsContent‘, {
cssPath: ‘../../Scripts/kindeditor/plugins/code/prettify.css‘,
uploadJson: ‘../../Scripts/kindeditor/upload_json.ashx‘,
fileManagerJson: ‘../../Scripts/kindeditor/file_manager_json.ashx‘,
allowFileManager: true,
afterCreate: function () {
var self = this;
K.ctrl(document, 13, function () {
self.sync();
K(‘form[name=example]‘)[0].submit();
});
K.ctrl(self.edit.doc, 13, function () {
self.sync();
K(‘form[name=example]‘)[0].submit();
});
},
afterBlur: function () { this.sync(); }
});
prettyPrint();
});
</script>
版权声明:本文为博主原创文章,未经博主允许不得转载。