asp.net無法獲取kindeditor文字編輯器內容的解決辦法
經過上網查資料,分析原因如下:
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>
===========================================================================
如果覺得對您有幫助,微信掃一掃支援一下: