The Dialog of jQuery UI cannot submit a solution to the problem.

Source: Internet
Author: User

Specific performance:
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.

Cause: JQuery will append the Dialog element to the Body instead of the form element. 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.

1st methods:
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:
Code: $ ("# dialog"). parent (). appendTo ("/html/body/form [0]");
Or
$ ("# 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.

2nd methods:
Add a div such as <div id = "dialog_target"> </DIV> and write the Dialog into the DIV.
$ ("# Dialog"). parent (). appendTo ("# dialog_target ");

3rd methods:
1. Modify the Dialog JS Code and add the code to the form instead of the body.
2. The custom HTML in Dialog is not used, but an IFRAME is directly added to move the HTML in it to another page, interaction with the parent page is OK (this method is used, so that the independent code can be reused)

2nd methods, server events can be responded, and the effect is also good, you can give priority.

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.