[jQuery] Multiple FCKEditor instances & validate plugin problem
Hey all.
Im having a hard time getting FCKEdtitor plugin and the "validate"
plugin to work along, so please, any advice is very welcome. Im using
the fckeditor plugin on all fckeditors, adding the to textareas using
the method described here:
http://www.fyneworks.com/jquery/FCKEditor/
First I was having that problem where when you try to submit the form,
validation returns erros for every required fckeditors
even if it actually has text on it. If you try to submit it again,
then it works. Is the same problem reported here:
http://groups.google.com/group/jquery-en/browse_thread/thread/e07ffa6d3c18b51c/e935c4d4156f3d1e?lnk=gst&q=fckeditor+validation#e935c4d4156f3d1e.
So I tried to add 'onclick="$.fck.update()"' on the submit button, and
it works. But only if you got a single FCKEditor instance in the page.
If you have multiple instances, "update" will only work for the first
one. Worst yet: after "update" has been called, the validate plugin
will always return errors for all required fckeditors (except the
first one), no mather if they has text on then, no mather how many
times you try to submit the form, rendering the form impossible to
submit. So, calling "$.fck.update()" actually seens to agravate the
problem, no fix it.
Ive been doing some debbuging in the fckeditor plugin and I believe I
found where the problem is. In the "content" method, we have this line
"var x = FCKeditorAPI.GetInstance(i);", where the the plugin tries to
retriveve the editor instance. What I found is that
"FCKeditorAPI.GetInstance(i);" will return "undefined" for every
instance except the first.
I might be wrong here, but taking a look at the "FCKeditorAPI" code I
found that all instances are supposed to be in the
"FCKeditorAPI.Instances" object, so they could be returned by
"FCKeditorAPI.GetInstance()". But if I do a "for in" in this object, I
will really only get the first fckeditor instance, and none of the
rest.
So that seens to be the problem, but what can I do about it? Im really
clueless here, perhaps Im doing something wrong, I dont know. Anybody
ever got to make "validate" and "fckeditor" plugins to work with a
form with multiple fckeditor fields? If you did, please give me some
advice.
In any case, thank you all for the atention.