开发者

CKEditor problems updating texarea's value

In my php program I display input forms either regular way on page load or in a dialog box using ajax calls.

There are two methods to create a CKEditor from textarea. Either to use jQuery

$("#textareaid").ckeditor();

or

window["textareaid"] = CKEDITOR.replace("开发者_Go百科textareaid");

Both methods creates my rich text editor inplace of my textarea in both cases either on page load or after an ajax call. That's fine.

Here starts the problems. In these conditions CKEditor initiates without any console errors, but it never updates textarea value and always sends old value.

1) If I create my textarea on page load and use $("#textareaid").ckeditor();. CKEditor initiates ok without any console errors but on regular form submit, the sent value is empty (old value).

2) If I create my textarea after an ajax call and use window["textareaid"] = CKEDITOR.replace("textareaid"); . Again CKEditor initiates correctly but if I do $("form").serialize() and alert the result I see that textarea value is empty (old value).

I can't create a demo page and upload right now and I know that no one will try to replicate this issue without my codes (at least I wouldn't because I'm so lazy)

I'll prepare a demo page to replicate this issue for you guys but until then I'm asking if someone here faced the same problem and know the reason or found a solution?

Thanks


You should be ok if you call:

 CKEDITOR.instances[your instance].updateElement();

'your instance' in the eaxmple would be simply textareaid since that's what you're using in the CKEDITOR.replace() function

before you serialize the form.

Had the exact same problems a couple of days ago :)


I just experienced this same symptom and it seems to be tied to using an id to select the object for the textarea instead of name with jQuery adapter. The reference material on the jQuery adapter does state that when it is a textarea it will automatically send this value back, so it may not validate correctly as a textarea with a jquery $("#myTextarea").ckeditor();

If you want to keep the id selector, an option is to use a hidden field with the final form field name that you send the value to when you submit the form. $("#myHiddenField").val($("#myTextarea").val());


after loading editor by replace, you may add this line

CKEDITOR.instances.textAreaClientId.on('blur', function() CKEDITOR.instances.textAreaClientId.updateElement();});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜