Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4041466
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:53:02+00:00 2026-05-20T12:53:02+00:00

My problem is that all JavaScript that I apply to an ajax-loaded JqueryUI Dialog

  • 0

My problem is that all JavaScript that I apply to an ajax-loaded JqueryUI Dialog doesn’t work when I close the dialog and then open another one up.

The few things that I have noticed is that when I close it, the html just becomes hidden, it isn’t actually deleted. Calling $dialog.dialog(“destroy”); doesn’t help. Deleting the hidden html doesn’t either. I’m not sure how to destroy the validation object (docs don’t say anything about it), or if doing that on dialog close will even help. I essentially just want to get back to the initial page load phrase when I close the dialog, so opening another one will recreate the validation object and such.

I had this problem with other widgets like TinyMCE, which would not initialize again once I close the first dialog and open others.

Here’s a simplified version of my code for one such dialog-

var create_contact_dialog = function () {
    var $contactDialog = $('<div></div>')
    .dialog({
        autoOpen: false,
        dialogClass: "contact_form_dialog",
    });
    $contactDialog.dialog('open');
    return $contactDialog;
};

$('#open_contact_form').live('click', function () {
    var $contactDialog = create_contact_dialog();
    $contactDialog.load('/contact_form', function () {
        contact_form_validator = $("#contact_form").validate({
            rules: {
                name: {
                    required: true
                },
            }
        });
    });
});

Any pointers are appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:53:03+00:00Added an answer on May 20, 2026 at 12:53 pm

    You will need to remove the DOM for the dialog once it has been closed, since the form that you load each time has the same exact ID (which is causing subsequent loads to still reference the first DOM with that ID). You can do this by providing a close function callback that deletes the contents of the dialog:

    var create_contact_dialog = function () {
        var $contactDialog = $('<div></div>')
        .dialog({
            autoOpen: false,
            dialogClass: "contact_form_dialog",
            close: function() {
                $contactDialog.remove();
            }
        });
        $contactDialog.dialog('open');
        return $contactDialog;
    };
    

    I provided an example of it here, if you remove the close function you will see that the alert does not work.

    jsfiddle example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the problem, that PHP replaces all spaces with underscores in POST and
So I'm been pounding on this problem all day. I've got a LinqDataSource that
One problem that I come across regularly and yet don't have a solution to
A problem that we need to solve regularly at my workplace is how to
The problem that I am having has to do with the need to keep
I have a problem that confuses my users, being that although an item is
This has been a problem that I haven't been able to figure out for
I have the problem that an specific step in Ant can only be executed
I am having the problem that I cannot select a specific XML node which
He're an interesting problem that looks for the most Pythonic solution. Suppose I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.