When ajaxform encounters tinymce

Source: Internet
Author: User

Before using ajaxform, I made a web form for small comments and used tinymce for text editing. To improve the user experience a little bit, we can use ajaxform to implement Ajax submission. However, an accident occurred. That is, each submission. When the first submission is made, ajaxform will not be able to obtain the content of the currently edited comment, that is, the content in textarea. You need to click submit again to submit the content of textarea.

The key is that the content on tinymce is not updated to textarea before submission. So I want to see if ajaxform has event binding before submission. I found that the formdata content has been filled in the beforesubmit event, although you can fill in the current tinymce content here (For details, refer to here), it is always a pretty solution.

To find out whether there are other ways to solve this problem, I checked the ajaxformSource codeIt is found that the author of the original ajaxform has proposed a unified solution for this problem, the specific sourceCodeAs follows:

// Hook for manipulating the form data before it is extracted;// Convenient for use with rich editors like tinymce or FCKeditorVaRVeto = {};This. Trigger ('form-Pre-serialize ',[This, Options, veto]);If(Veto. Veto) {log ('ajaxsubmit: Submit vetoed via form-Pre-serialize trigger ');Return This;}

Sure enough, there is a corresponding event that allows us to update tinymce data to textarea before formdata is assigned a serial number. You only need to bind the form-Pre-serialize event of form.

So one of my codes came out like this: (similar to FCKeditor)

// Bind form using 'ajaxform'$ ('# Commentform'). ajaxform (options );// Bind the form-Pre-serialize event and save the data of tinymce to textarea before the form-serilaize event is triggered.$ ('# Commentform'). BIND ('form-Pre-serialize ',Function(Event, form, options, veto) {tinymce. triggersave ();
 
});
 
 
 
^_^ Hope to be useful to you...

Technorati:Jquey, ajaxform, Ajax, tinymce

 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.