如何在ckeditor编辑器中获取保存事件?

时间:2016-01-27 12:17:43

标签: javascript jquery ckeditor

如何在ckeditor中获取save事件,以便我可以调用ajax来保存数据。

我在这里上传图片 enter image description here

2 个答案:

答案 0 :(得分:3)

我得到了解决方案,请使用此

 CKEDITOR.plugins.registered['save'] = {
  init: function (editor) {
     var command = editor.addCommand('save',
     {
          modes: { wysiwyg: 1, source: 1 },
          exec: function (editor) { // Add here custom function for the save button
          alert('You clicked the save button in CKEditor toolbar!');
          }
     });
     editor.ui.addButton('Save', { label: 'Save', command: 'save' });
  }

}

答案 1 :(得分:1)

.formSubmit是表单的类名,

var data = CKEDITOR.instances.editor1.getData();这是textarea的数据

 $('.formSubmit').submit( function(){
 var data = CKEDITOR.instances.editor1.getData();
 $.ajax({
      type: 'POST',
      url: 'ck_bienban_1_luu.php',// url of phpcode save
      data: {
           data: data,
       },
         success: function() {
           },
       });
return(false);

}
);