tags:

views:

43

answers:

2

Hello,

I'm having issues with dynamic form with wysiwyg editor. I'm using FCKEditor (I'm forced to).

From the begining, I create a cute form in Fencybox, working correctly. I'm having only one small isssue, form is not sending any value. According to documentation link text everything is implemented correctly.

I'm trying to get editor content by:

var comment = $("#comment").val();

Not working, wondering why. Do you have any suggestions?

Edit alert(comment); return nothing. But when I put in:

success: function(html){
    alert(comment);
}

it works correctly. Any ideas?

Regards, Tom

A: 

I think I see what you want... the jQuery selector you have there won't return anything because you are trying to get the value of the form (#comment is the id of your form)

The editor content is actually inside of an iframe or textarea depending if you are looking at the source... try this:

var content = ($('textarea.cke_source').length) ? $('textarea.cke_source').val() : $('table.cke_editor iframe').contents().find('body').html();

Edit: Use Jon's answer... now that I look again, I think this was for CKEditor and not FCKEditor, it's easy to confuse the two.

fudgey
Thanks for help **fudgey** ;)
Tom
+1  A: 

Use the CKEditor JavaScript API to retrieve the HTML value:

var comment = FCKeditorAPI.GetInstance('comment_body').GetHTML();
Jon Benedicto
+1 - Yeah I was sure there was a better way with the API, I just couldn't find it :P
fudgey
Jon, of course, **correct answer**. Thank you for your help.
Tom