CK Editor validates second time

后端 未结 3 1143
星月不相逢
星月不相逢 2020-12-12 08:11

I have two CKEditors in my HTML (I mean to say multiple ckeditors).

Also I am using Validate plugin for checking if CKEditor is empty,if empty show error.

Va

3条回答
  •  孤街浪徒
    2020-12-12 08:46

    I tried following solution and it worked .

            
               
    

    If there is only 1 ckEditor

    for (instance in CKEDITOR.instances) {
    
        CKEDITOR.instances[instance].on("instanceReady", function () {
    
            //set keyup event
            this.document.on("keyup", function () { CKEDITOR.instances[instance].updateElement(); });
            //and paste event
            this.document.on("paste", function () { CKEDITOR.instances[instance].updateElement(); });
    
        });
    }                                   
    

    If there are more than 1 ckEditor(in my case 2)

    CKEDITOR.instances["txtDesc0"].on("instanceReady", function () {
    this.document.on("keyup", function () { CKEDITOR.instances["txtDesc0"].updateElement(); });
    this.document.on("paste", function () { CKEDITOR.instances["txtDesc0"].updateElement(); });
    this.document.on("cut", function () { CKEDITOR.instances["txtDesc0"].updateElement(); });
    });
    
    CKEDITOR.instances["txtDesc1"].on("instanceReady", function () {
    this.document.on("keyup", function () { CKEDITOR.instances["txtDesc1"].updateElement(); });
    this.document.on("paste", function () { CKEDITOR.instances["txtDesc1"].updateElement(); });
    this.document.on("cut", function () { CKEDITOR.instances["txtDesc1"].updateElement(); });
    });             
    

提交回复
热议问题