您的位置:首页 > Web前端 > JQuery

KindEditor提交用jquery获取不到数据的解决方法

2015-11-15 00:04 686 查看
<script>

var editor;
KindEditor.ready(function(K) {
editor = K.create('#editor_id');
如果是用ajax方式提交的话,这样是获取不到数据的,最关键的是数据不同步
在html页面中的javascript程序要这样写
<script type="text/javascript">
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>


简单模式

var editorMini = KindEditor.create('.editor', {
width: '100%',
height: '250px',
filterMode: false, //默认不过滤HTML
resizeType: 1,
afterBlur: function () { this.sync() },
uploadJson: '{config.webpath}tools/upload_ajax.ashx?action=EditorFile&IsWater=1',
items: [
'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
'insertunorderedlist', '|', 'emoticons', 'image', 'link']

});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: