Solution to failure to submit a form in the jQuery UI Dialog control

Source: Internet
Author: User

Recently, when using the Dialog control of jQuery UI, we found that if a form is placed in this control, all forms cannot be submitted normally, as shown below:
1. The submit button is invalid. No response is returned after you click the button.

2. Even if the page is submitted using other means, the server cannot obtain the form data in the Dialog.

After studying the page source code, it is found that the HTML elements dynamically generated during the initialization of the jQuery UI Dialog control are added to the end of the page and the end of the form element, the original Dialog template (which contains form elements) is moved to the dynamically generated HTML element. That is to say, the form originally in the form is moved out of the form after the Dialog initialization, which leads to all the forms in the Dialog template being invalid.

I wonder whether the Dialog design of jQuery UI is a function or a bug. In order to implement normal page submission in the Dialog, according to the above analysis, I found a simple solution-in the "open" event handler of the jQuery UI control, I moved the HTML elements dynamically generated by the Dialog control to the form element. The Code is as follows:
Copy codeThe Code is as follows:
$ ("# Dlg"). dialog ({
Open: function (){
$ ("Body> div [role = dialog]"). appendTo ("form # aspnetForm ");
}
});

In the Code, "aspnetForm" is the ID of the current page form Element automatically generated by the ASP. NET application. You can replace it with the form ID of your own page.

Related Article

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.