CK Editor validates second time

后端 未结 3 1133
星月不相逢
星月不相逢 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:42

    jQuery.validator.setDefaults({
        ignore: [],
        // with this no hidden fields will be ignored E.g. ckEditor text-area
    });
    

    I observed the validation was working on 2nd submit. The reason is, ckEditor hides the actual text area and puts an iframe as an editor instance, and on submit it pushes the content to the text area. Which means, the validation on the TextArea gets fired on stale data. To fix this problem, I am updating my TextArea on the text change of the editor instance.

        for (instance in CKEDITOR.instances) {
            CKEDITOR.instances[instance].on('change', function ()
            {
                var editorName = $(this)[0].name;
                CKEDITOR.instances[editorName].updateElement();
            });
        }
    

提交回复
热议问题