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.