现在的位置: 首页 > phpweb > 正文
给phpweb换编辑器 用kindeditor ajax 提交注意问题
2012年11月01日 phpweb ⁄ 共 2998字 暂无评论

下载最新版的 kindeditor

 我这有个自己整理好的

 

 

kindeditor 用ajax提交会出现如下问题: 提交第二次才能获取到真实的值。用如下方法解决:

加一个,afterChange: function (e) { this.sync() }  同步下数据即可

替换就ok:

 

一个文件下如何防两个编辑器:

 

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Examples</title>
<script charset="utf-8" src="../kindeditor-min.js"></script>
<script charset="utf-8" src="../lang/zh_CN.js"></script>
<script>
KindEditor.ready(function(K) {
    LoadEditor('message1', 'example');
    LoadEditor('message2', 'example');
    LoadEditor('message3', 'example');
});
function LoadEditor(TextName, FormName) {
    var editor1 = KindEditor.create('textarea[name="' + TextName + '"]', {
        uploadJson: '../lgw_kindeditor/upload_json.asp',
        fileManagerJson: '../lgw_kindeditor/file_manager_json.asp',
        allowFileManager: true,
        afterCreate: function() {
            var self = this;
            KindEditor.ctrl(document, 13,
            function() {
                self.sync();
                KindEditor('form[name=' + FormName + ']')[0].submit();
            });
            KindEditor.ctrl(self.edit.doc, 13,
            function() {
                self.sync();
                KindEditor('form[name=' + FormName + ']')[0].submit();
            });
        }
    });
    return editor1;
}
</script>
</head>

<body>
<form name="example">
  <textarea name="message1" style="width:800px;height:400px;visibility:hidden;"></textarea>
  <textarea name="message2" style="width:800px;height:400px;visibility:hidden;"></textarea>
  <textarea name="message3" style="width:800px;height:400px;visibility:hidden;"></textarea>
</form>
</body>
</html>

 商城添加调用代码

 


<link rel="stylesheet" href="../../kindeditor/themes/default/default.css" />
 <link rel="stylesheet" href="../../kindeditor/plugins/code/prettify.css" />
 <script charset="utf-8" src="../../kindeditor/kindeditor.js"></script>
 <script charset="utf-8" src="../../kindeditor/lang/zh_CN.js"></script>
 <script charset="utf-8" src="../../kindeditor/plugins/code/prettify.js"></script>
 
 <script>
KindEditor.ready(function(K) {
    LoadEditor('body', 'form');
    LoadEditor('canshu', 'form');
 
});
function LoadEditor(TextName, FormName) {
    var editor1 = KindEditor.create('textarea[name="' + TextName + '"]', {
   cssPath : '../../kindeditor/plugins/code/prettify.css',
    uploadJson : '../../kindeditor/upload_json.php',
    fileManagerJson : '../../kindeditor/file_manager_json.php',
        allowFileManager: true,
        afterCreate: function() {
            var self = this;
            KindEditor.ctrl(document, 13,
            function() {
                self.sync();
                KindEditor('form[name=' + FormName + ']')[0].submit();
            });
            KindEditor.ctrl(self.edit.doc, 13,
            function() {
                self.sync();
                KindEditor('form[name=' + FormName + ']')[0].submit();
            });
        },afterChange: function (e) { this.sync() }

    });
    return editor1;
}
</script>

 

 <textarea name="body" style="width:800px;height:400px;visibility:hidden;"></textarea>
 

给我留言

您必须 [ 登录 ] 才能发表留言!

×