Ckeditor update textarea

后端 未结 10 1627
抹茶落季
抹茶落季 2020-12-01 03:10

I am trying to get the ckeditor working. Obviously it doesn\'t make use of the textarea so on submit the form doesn\'t submit the text in the editor. Beceause I make use of

10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 03:13

    Combination of all of the above answers into one.

    Create a new custom.js file and add this:

    CKEDITOR.on('instanceReady', function(){
      $.each( CKEDITOR.instances, function(instance) {
    
        CKEDITOR.instances[instance].on("instanceReady", function() {
          this.document.on("keyup", CK_jQ);
          this.document.on("paste", CK_jQ);
          this.document.on("keypress", CK_jQ);
          this.document.on("blur", CK_jQ);
          this.document.on("change", CK_jQ);
        });
      });
    
    });
    
    function CK_jQ() {
      for ( var instance in CKEDITOR.instances ) { CKEDITOR.instances[instance].updateElement(); }
    }
    

    You don't have to worry about the name of the textarea, just add a class ckeditor in the textarea, the above and you are done.

提交回复
热议问题