Solution to conflict between xheditor and validate plug-in

Source: Internet
Author: User

Both xheditor and validate are excellent jquery plug-ins, but they are combined. If the initialization order is incorrect, some subtle results will appear. I used these two plug-ins at the same time when I made a text submission page. One is used to display the rich text editor, the other is used to verify whether the user entered the content, and my Initialization CodeAs follows: Copy codeThe Code is as follows: $ ("# form1"). Validate ({
Rules :{
Body: "required"
},
Messages :{
Body: "enter the body"
}
});
VaR editor = $ ("# Body"). xheditor (true ,{
Tools: "simple"
});

However, even if the content has been filled in, the "please fill in the body" is still displayed when you click the submit button for the first time. The second time you click the submit button, it will actually be submitted, I was puzzled by this phenomenon. What is the problem?

Because these two plug-ins are used on multiple pages in the current project, and one of the pages is normal when submitted, I carefully compared the normal and problematic pages, the initialization sequence is different. Initialize the xheditor on the page that can be submitted normally, and then initialize the validate. The opposite is true for the problematic page! This problem can be solved as well. You only need to reverse the initialization sequence of the two plug-ins so that xheditor can initialize the plug-ins before validate to avoid the issue of "Two submissions.

I hope this article will help you.

Ckeditor also has this problem. The solution is to get the content in the editor and put it in textarea.

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.