Ckeditor update textarea

后端 未结 10 1604
抹茶落季
抹茶落季 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:30

    Before submit do:

    for(var instanceName in CKEDITOR.instances)
        CKEDITOR.instances[instanceName].updateElement();
    
    0 讨论(0)
  • 2020-12-01 03:35

    Thanks @JohnDel for the info, and i use onchange to make it update every change.

    CKEDITOR.on('instanceReady', function(){
       $.each( CKEDITOR.instances, function(instance) {
        CKEDITOR.instances[instance].on("change", function(e) {
            for ( instance in CKEDITOR.instances )
            CKEDITOR.instances[instance].updateElement();
        });
       });
    });
    
    0 讨论(0)
  • 2020-12-01 03:35
    CKEDITOR.instances["ckeditor"].on("instanceReady", function()
    {
    //set keyup event
    this.document.on("keyup", CK_jQ);
    
    //and paste event
    this.document.on("paste", CK_jQ);
    })
    
    0 讨论(0)
  • 2020-12-01 03:37

    On load:

    $(function () {
      setTimeout(function () {
        function CK_jQ(instance) {
          return function () {
            CKEDITOR.instances[instance].updateElement();
          };
        }
    
        $.each(CKEDITOR.instances, function (instance) {
          CKEDITOR.instances[instance].on("keyup", CK_jQ(instance));
          CKEDITOR.instances[instance].on("paste", CK_jQ(instance));
          CKEDITOR.instances[instance].on("keypress", CK_jQ(instance));
          CKEDITOR.instances[instance].on("blur", CK_jQ(instance));
          CKEDITOR.instances[instance].on("change", CK_jQ(instance));
        });
      }, 0 /* 0 => To run after all */);
    });
    
    0 讨论(0)
提交回复
热议问题