2016-01-27 88 views
2

如何獲取ckeditor中的保存事件,以便我可以調用ajax來保存數據。如何獲取ckeditor編輯器中的保存事件?

在這裏,我上傳圖片 enter image description here

+0

檢查[獲取和保存數據(http://docs.ckeditor.com/#!/guide/dev_savedata)文檔和SDK樣品:[數據保存CKEditor的更換Textarea](http://sdk.ckeditor.com/samples/savetextarea.html)和[Ajax應用程序中的CKEditor](http://sdk.ckeditor.com/samples/saveajax.html)。 –

回答

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

.formSubmit是類名,

VAR數據= CKEDITOR。 instances.editor1.getData();這是文本區域的數據

$('.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); 

} 
); 
相關問題