Dynamic form with wysiwyg issues
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, w开发者_Go百科orking 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
Use the CKEditor JavaScript API to retrieve the HTML value:
var comment = FCKeditorAPI.GetInstance('comment_body').GetHTML();
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.
精彩评论