views:

442

answers:

1

I am using ajaxForm function to submit my form that has nicEdit html editor as well but when I tried to submit the form for the first time the content of the nicEdit is not included... Is there a way that I can intercept the data submitted so I can edit the form data? or maybe add values to the form-data before it actually gets submitted? something like...

var options = { type: 'blahblah', success: blahblah, beforeSerialize: alterData } $('bla').ajaxForm(options)

function alterData(formdata){ // like adding a data here formdata['newdata'] = im a new data! // then return the new form data for submit return formdata; }

is there something similar to this? Appreciate all the help...

A: 

Well I figured it out just an hour ago after posting this, so if anyone has the same problem here is the solution:

there really is a beforeSerialize option!

... beforeSerialize: alterData ...

function alterData(formData,options){ var nicEdit_content = nicEditors.findEditor('id_of_textarea').getContent(); formData.each(function(){ $(this).find('#gth_text').val(nicEdit_content); }) return true; // Return true to go back to normal processing! }

it works for me! You can probably do the same with other online html editors such as fckeditor,tinymce blah blah..

Chopnut