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 6726599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:56:46+00:00 2026-05-26T09:56:46+00:00

I have 2 pages. The first page has a dialog that gets populated with

  • 0

I have 2 pages. The first page has a dialog that gets populated with content from another page via jQuery’s load(). This content also has a dialog in it. For some reason, the first time the content is loaded, it works just fine, but if it is used again, the dialog content from the second page is being shown as a section of that page instead of just being a hidden dialog.

Here is a sample I whipped up quick just to see if it was something else on the page or if it’s something wrong with how I am doing it. It’s obviously me. 🙂

Page 1:

<!DOCTYPE html>
<html>
<head>
    <link id="Link1" type="text/css"     href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/ui-lightness/jquery-ui.css" rel="stylesheet" />
</head>
<body>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>

<div>
    Document 1.
    <a class="ajax" href="http://localhost/doc2.html" >Click Here</a>
</div>

<script>
    $(document).ready(function () {
        $('a.ajax').click(function () {
        var url = this.href;
        var dialog = $('<div></div>').appendTo('body');
        dialog.load(
                url,
                null,
                function (responseText, textStatus, XMLHttpRequest) {

                  dialog.dialog({
                    resizable: false,
                    modal: true,
                    width: '600',
                    height: 'auto',
                    position: 'center',
                    show: "fade",
                    hide: "fade",
                    center: true,
                    close: function (event, ui) {
                      dialog.remove();
                    }
                  });
                }
        );

        return false;
      });
    });
</script>

</body>
</html>

Page 2:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>

<div>
    document 2
    <button id="popupButton">Click here to show popup</button>
</div>

<div id="dialog-message">
   This is the popup in document 2.
</div>

<script>
      $(document).ready(function () {
        $("#dialog-message").dialog({
          show: 'blind',
          autoOpen: false,
          modal: true,
          resizable: false,
          width: 900,
          height: 400,
          buttons: {
            Ok: function () {
              $(this).dialog("close");
            }
          }
        });

       $("#popupButton")
              .button()
              .click(function () {
                $("#dialog-message").dialog("open");
              });
      });
</script>

</body>
</html>

*Note – for some reason the dialog in page 2 is not working, but it is in my other pages, so I’m not worried about that. I’m just worried about the strange behavior of the dialog content showing up in the page.

  • 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-26T09:56:46+00:00Added an answer on May 26, 2026 at 9:56 am

    I found a work around, but unsure this is the proper solution. Since it works, I’m going to run with it.

    In page 1 I changed the javascript:

    <script>
        $(document).ready(function () {
            $('a.ajax').click(function () {
                var url = this.href;
                var dialog1 = $('<div></div>').appendTo('body');
                dialog1.load(url, null,
                        function (responseText, textStatus, XMLHttpRequest) {
                          dialog1.dialog({
                            resizable: false,
                            modal: true,
                            width: '600',
                            height: 'auto',
                            position: 'center',
                            show: "fade",
                            hide: "fade",
                            center: true,
                            close: function (event, ui) { 
                                dialog1.remove(); 
                                $("#dialog-message").remove();
                            }
                          });
                        }
                );
    
                return false;
            });
        });
    </script>
    

    In page 2, I had to do this to make the popup work:

    <script>
        $(document).ready(function () {
            $("#dialog-message").hide();
    
            $("#popupButton").button().click(function () {
                $("#dialog-message").dialog({
                  show: 'blind',
                  autoOpen: true,
                  modal: true,
                  resizable: false,
                  width: 900,
                  height: 400,
                  zIndex: 9999,
                  open: function(event, ui) { $("dialog-message").show(); },
                  buttons: {
                    Ok: function () {
                      $(this).dialog("close");
                    }
                  }
                });
            });
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two pages that inherit from one master page, First.aspx or second.aspx. Navigation
Right now, I have a jQuery UI pop-up dialog that reads from an external
I have a jQuery modal dialog that loads a different page on an iframe.
I have a report where the first page has a certain top and bottom
Currently I have two pages: The first page contains an input form, and the
I have two pages, on the first page after an event happens I change
lets say i have two pages links.html & contents.php ... first page contains only
I have a dialog box that has settings associated with it. When the user
Let's explain the context: I have a person form inside a jquery dialog that
I have a website in c#, in the first page I have some listbox,

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.