views:

707

answers:

1

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.

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:

"you could work around this problem by calling CKEDITOR.editor::updateElement right before every validation routine."

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');
 });
});

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

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

A: 

thanks czarchaic,

I solved it by writing:

CKEDITOR.instances.prod_description.updateElement();

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

Jorre