Invalid JQuery ui dialog (close) Solution

Source: Internet
Author: User

This article introduces how to call the close () function when using JQuery ui dialog. If you encounter such problems, refer to it.

The problem is as follows:
At first I used floatLayer. show pops up A layer and loads A form through ajax (in place of Form A below). When the form is loaded, I initialize JQuery ui dialog in the form, and configure some parameters.
Code:

The Code is as follows: Copy code
$ (Function ()
{
// Initialization parameters
$ ("# Getcompany"). dialog ({autoOpen: false, width: 760, height: $ companyselectboxheight, closeOnEscape: false });
}

In this case, I call to open:

The Code is as follows: Copy code

// Open
$ ("# Getcompany"). dialog ('open ');
Or close

// Close
$ ("# Getcompany"). dialog ('close ');

Everything works.
However, it is normal for me to close form A and call the preceding method to Open Form.

The final solution is to change the object $ ("# getcompany") to a global variable.
For example:

The Code is as follows: Copy code
$ (Function ()
{
// Initialization parameters
GETCOMPANY = $ ("# getcompany ");
GETCOMPANY. dialog ({autoOpen: false, width: 760, height: $ companyselectboxheight, closeOnEscape: false });
}
// Open
GETCOMPANY. dialog ('open ');
// Close
GETCOMPANY. dialog ('close ');

So there is no problem. Pai_^
Note: you cannot add var before GETCOMPANY initialization, that is, you cannot write var GETCOMPANY =$ ("# getcompany ");

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.