CKEditor,AJAX保存

前端之家收集整理的这篇文章主要介绍了CKEditor,AJAX保存前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
您能否提供一个示例,说明如何使用CKEditor工具栏中的“保存”按钮设置C​​KEditor以通过AJAX进行保存?

我有兴趣创建一个CKEditor AJAX保存页面,但我们没有在他们的网站上看到任何示例.

谢谢!

尝试直接从_source / plugins / save / plugin.js复制并根据需要进行更改.在/ path / to / ckeditor / plugins中创建新插件(即不在/ path / to / ckeditor / _source / plugins中).例如,在/ path / to / ckeditor / plugins中创建一个新目录“AjaxSave”,然后在该目录中创建一个文件“plugin.js”.然后在该文件中做这样的事情(改编自源文件夹中的正常“保存”插件):
  1. (function()
  2. {
  3. var saveCmd =
  4. {
  5. modes : { wysiwyg:1,source:1 },exec : function( editor )
  6. {
  7. var $form = editor.element.$.form;
  8. if ( $form )
  9. {
  10. try
  11. {
  12. editor.updateElement();
  13. //Here is where you put your ajax submit function. For example... if you are using
  14. // jQuery and the ajaxform plugin,do something like this:
  15. $($form).ajaxSubmit({
  16. success: function(response){
  17. //do something with the response
  18. }
  19. });
  20. } catch ( e ) {
  21. //alert(e);
  22. }
  23. }
  24. }
  25. }
  26. var pluginName = 'ajaxsave';
  27. CKEDITOR.plugins.add( pluginName,{
  28. init : function( editor )
  29. {
  30. var command = editor.addCommand( pluginName,saveCmd );
  31. command.modes = { wysiwyg : !!( editor.element.$.form ) };
  32. editor.ui.addButton( 'AjaxSave',{
  33. label : editor.lang.save,command : pluginName,icon: "/img/save.png"
  34. });
  35. }
  36. });
  37. })();

然后在定义工具栏的配置中,将“AjaxSave”更改为“Save”.

编辑:你还必须添加config.extraPlugins =“ajaxsave”;到配置.

猜你在找的Ajax相关文章