Loading Multiple CKEditors is Slow

前端 未结 3 2018
感情败类
感情败类 2021-01-16 01:26

I have a lot of ckeditors on one web page for students to enter their data. I have a lot of ckeditors because each one is for one variable. Unfortunately, an input text fiel

3条回答
  •  太阳男子
    2021-01-16 01:56

    Yes according to @Roman answer, you should only initialize ckeditor when the input field is click then if it loses focus, destroys it.

    $('.editable').click(function() {
      editor = CKEDITOR.replace(this);
      editor.on('blur', function(e)
      {
        var okToDestroy = false;
    
        if (e.editor.checkDirty()) {
           // get data with e.editor.getData() and do some ajax magic
           okToDestroy = true;
         } else {
           okToDestroy = true;
         }
    
        if (okToDestroy )
          e.editor.destroy();
    
      });
    });
    

    Here .editable is your input field. Reference: link here

提交回复
热议问题