Dialog of JQuery UI solutions for problems that cannot be submitted _jquery

Source: Internet
Author: User
The specific performance is:
1. Failure of the Submit button, no response after clicking.
2. Even if you use other means to make a page submit, the server side is not able to access the form data in the dialog.

Reason: jquery will append the dialog elements into the body, not the form inside. After studying the page source, we found that the dynamically generated HTML elements were added to the end of the page, the form element after the JQuery UI dialog control initialization, and the original dialog template part (which contains the form element) was also moved to the dynamically generated HTML element. That is, a form that was originally in the form was moved outside the form after the dialog initialization, which caused the form to be completely invalidated in the dialog template.

The 1th method:
Don't know the jquery UI dialog This design is a feature or a bug. In order to implement normal page submissions within dialog, based on the above analysis, I found a simple solution-moving the dynamically generated HTML element of the dialog control into the form element in the JQuery UI control's "open" event handler, the code reads as follows:
Use code: $ ("#dialog"). Parent (). Appendto ("/html/body/form[0]");
Or
$ ("#dlg"). Dialog ({
Open:function () {
$ ("Body > Div[role=dialog]"). Appendto ("Form#aspnetform");
}
});
The "Aspnetform" in the code is the current page form element ID that is automatically generated by the ASP.net application, and you can replace it with the form ID of your own page.

The 2nd method:
Add a div with a <div id= "Dialog_target" ></div> and then write the dialog into the Div.
$ ("#dialog"). Parent (). Appendto ("#dialog_target");

The 3rd method:
1, modify the dialog JS code, add code to the form, not the body inside
2, dialog internal custom HTML is not used, and directly add an IFRAME, the inside of the HTML moved to another page, and then the parent page to interact with OK (I use this method, so that these independent code can be reused

The 2nd approach, server events can respond, the effect is good, you can give priority.

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.