Hello,
I am using ajax to submit a form with FCK editors in them.
However, sometimes, seemingly randomly, the new information in the FCK editors is not updated, and the user's information does not save. I'm trying to figure out why.
Basically what happens is, each page loads it contains this code right at the top of the page:
<script type='text/javascript'>
CMS_FCK_clear_list();
</script>
which clears an array of FCK editors. The editors are displayed within the page, and there is an oncomplete function that adds each loading editor to a list of editors (hopefully they should run after CMS_FCK_clear_list() )it should run after . Then, when the page is submitted, I use the editor array to call UpdateLinkedField on each editor. Why would this cause the text from editors not to be sent to the server sometimes? Any ideas?
If it helps, it seems to happen more when there are more FCK editors on the page.
If you want to see (some of) the code, here it is:
var fck_list = new Array()
function FCKeditor_OnComplete( editorInstance )
{
fck_list[fck_list.length] = editorInstance
}
function CMS_FCK_prepare_submit()
{
for (i=0; i< fck_list.length; i++ ) {
fck_list[i].UpdateLinkedField();
}
}
function CMS_FCK_clear_list()
{
fck_list = new Array();
}
// This is called when user clicks submit
function submitForm(form)
{
CMS_FCK_prepare_submit();
content_div = 'selected_tab';
form_params = Form.serialize(form, true);
var ajax_params = {
'method':form.method,
'parameters':form_params,
'evalScripts': true
};
new Ajax.Updater(content_div, form.action, ajax_params);
}
I am using ajax to submit a form with FCK editors in them.
However, sometimes, seemingly randomly, the new information in the FCK editors is not updated, and the user's information does not save. I'm trying to figure out why.
Basically what happens is, each page loads it contains this code right at the top of the page:
<script type='text/javascript'>
CMS_FCK_clear_list();
</script>
which clears an array of FCK editors. The editors are displayed within the page, and there is an oncomplete function that adds each loading editor to a list of editors (hopefully they should run after CMS_FCK_clear_list() )it should run after . Then, when the page is submitted, I use the editor array to call UpdateLinkedField on each editor. Why would this cause the text from editors not to be sent to the server sometimes? Any ideas?
If it helps, it seems to happen more when there are more FCK editors on the page.
If you want to see (some of) the code, here it is:
var fck_list = new Array()
function FCKeditor_OnComplete( editorInstance )
{
fck_list[fck_list.length] = editorInstance
}
function CMS_FCK_prepare_submit()
{
for (i=0; i< fck_list.length; i++ ) {
fck_list[i].UpdateLinkedField();
}
}
function CMS_FCK_clear_list()
{
fck_list = new Array();
}
// This is called when user clicks submit
function submitForm(form)
{
CMS_FCK_prepare_submit();
content_div = 'selected_tab';
form_params = Form.serialize(form, true);
var ajax_params = {
'method':form.method,
'parameters':form_params,
'evalScripts': true
};
new Ajax.Updater(content_div, form.action, ajax_params);
}
Re: Ajax - UpdateLinkedField doesn't work?
I believe that the problem is that the code in the page:
<script type='text/javascript'>
CMS_FCK_clear_list();
</script>
Is not guaranteed to run before the editors initialize. Apparently, this is especially the case with prototype on IE. Occasionally the array of editors will be cleared after they have all initialized. So UpdateLinkedField will not be called on those editors. The solution seems to be to call clear list in the onComplete function.
var ajax_params = {
'method':form.method,
'parameters':form_params,
onComplete: new Function("CMS_FCK_clear_list();"),
'evalScripts': true
};
Oddly enough it seemed to happen when I had many editors to initialize, for example, 14.