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”.然后在该文件中做这样的事情(改编自源文件夹中的正常“保存”插件):
(function()
{
  var saveCmd =
  {
    modes : { wysiwyg:1,source:1 },exec : function( editor )
    {
      var $form = editor.element.$.form;
      if ( $form )
      {
          try
          {
            editor.updateElement();
//Here is where you put your ajax submit function. For example... if you are using
// jQuery and the ajaxform plugin,do something like this:
            $($form).ajaxSubmit({
               success: function(response){
                 //do something with the response
               }
            });
          } catch ( e ) {
            //alert(e);
          }
      }
    }
  }
  var pluginName = 'ajaxsave';
  CKEDITOR.plugins.add( pluginName,{
     init : function( editor )
     {
        var command = editor.addCommand( pluginName,saveCmd );
        command.modes = { wysiwyg : !!( editor.element.$.form ) };
        editor.ui.addButton( 'AjaxSave',{
            label : editor.lang.save,command : pluginName,icon: "/img/save.png"
         });
     }
   });
})();

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

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

相关文章

IE6是一个非常老旧的网页浏览器,虽然现在很少人再使用它,但...
PHP中的count()函数是用来计算数组或容器中元素的个数。这个...
使用 AJAX(Asynchronous JavaScript and XML)技术可以在不...
Ajax(Asynchronous JavaScript and XML)是一种用于改进网页...
本文将介绍如何通过AJAX下载Excel文件流。通过AJAX,我们可以...
Ajax是一种用于客户端和服务器之间的异步通信技术。通过Ajax...