使用CKEditor与jQuery验证插件不工作

问题描述:

我使用CKeditor和jist验证插件从basistance。我的textarea(与CKEditor上)由jQuery验证,但只有第二次点击我的提交按钮后工作。

I'm using CKeditor and the jQuery validation plugin from basistance. My textarea (with the CKEditor on it) is being validated by jQuery, but that only works after the second click on my submit button.

简而言之:
第一次在CKEditor中输入数据时提交表单,它说字段为空。

In short: the first time I submit the form when data is entered in the CKEditor, it says "field is empty". The second time it says it's ok and the form is being submitted.

我为此读了一个解决方案:

I read a solution for this:

我找不到如何解决这个问题,你可以通过在每个验证程序之前调用CKEDITOR.editor :: updateElement来解决这个问题。实现它:

I cannot find how to implement it though:

$(document).ready(function(){
    CKEDITOR.replace( 'prod_description',
    {
        toolbar: 'MyToolbar'
    }
    );

    $("#btnOk").click(function(){
        CKEDITOR.instances.editor1.updateElement();
        alert('click');
    });
});

这总是给我错误:CKEDITOR.instances.editor1 is undefined

This always gives me the error: "CKEDITOR.instances.editor1 is undefined"

有关如何解决这个问题的任何想法。 CKEditor的文档在这里:
http:// docs。 cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#updateElement

Any ideas on how to solve this. Documentation from CKEditor is here: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#updateElement

感谢czarchaic,

thanks czarchaic,

我解决了这个问题:

CKEDITOR.instances.prod_description.updateElement();

CKEDITOR.instances.prod_description.updateElement();

其中prod_description是与CKeditor链接的textare的名称。

where "prod_description" is the name of your textare with CKeditor linked to it.