我刚刚创建了一个插件ajax保存。我查看过文档,而不是让我感到困惑,以实现它。 当点击并通过ajax php保存内容时,如何使按钮工作?目前我无法获得内容。
文件夹:/plugins/ajaxsave/plugin.js
var saveCmd = {
modes : { wysiwyg:1 },
exec : function(editor) {
**var $content = editor.instances.editor1.getData(); ?????**
var $data = {'keyId': 1, 'token': TOKEN, 'content': $content};
$.ajax({
type: 'post',
url: '../../script/php/file.php',
data: $data,
dataType: 'json',
cache: false,
success: function(data) {
alert('OK');
},
error: function(data){
alert('fatal error');
}
});
CKEDITOR.instances.editor1.destroy();
}
}
CKEDITOR.plugins.add('ajaxsave', {
init:function(editor) {
var pluginName = 'ajaxsave';
var command = editor.addCommand(pluginName,saveCmd);
command.modes = {wysiwyg:1 };
editor.ui.addButton('ajaxsave', {
label: 'Save text',
command: pluginName,
toolbar: 'undo,1',
icon: this.path+'save.png'
});
}
});
问题是什么?它会给你一个错误?它没有保存吗?请带我们解决问题。 – Trufa
@Trufa它不识别可编辑的内容。我如何获取内容并通过ajax传递它。 – tonoslfx