Xheditor solution to the Validate plug-in conflict _jquery

Source: Internet
Author: User
Both xheditor and validate are excellent jQuery plug-ins, but the combination of the two is good, if the initialization is not in the wrong order, there will be some subtle results. I used both plug-ins when I made a text submission page, one for the rich text editor, one for verifying that the user was filled in, and my initialization code was as follows:
Copy Code code as follows:

$ ("#form1"). Validate ({
Rules: {
Body: "Required"
},
Messages: {
Body: "Please fill in the text"
}
});
var editor = $ ("#Body"). Xheditor (True, {
Tools: "Simple"
});

However, in the submission, although the content has been filled out, the first time you click the Submit button will still show "please fill in the body", the second click on the Submit button to be really submitted, this phenomenon let me baffled, what exactly is the problem?

Because there are several pages in the current project that use these two plug-ins, and one of the pages is normal to submit, so I carefully compared the normal and problematic page similarities and differences, found that the order of initialization is not the same. In the normal submission of the page first initialized Xheditor, and then initialize the validate, and the problem of the page is the opposite, the original is so! Problem to this also use solves, as long as reverses the initialization order of these two plug-ins, let Xheditor before validate initialize, can avoid "two submit" the problem occurs.

I hope this article is helpful to you.

CKEditor also have this problem, my solution is to get editor content into the textarea in the good.

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.