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

  • Home
  • SEARCH
  • 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 843249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:05:44+00:00 2026-05-15T06:05:44+00:00

When I call the function, the dialog doesn’t work. If I move the dialog

  • 0

When I call the function, the dialog doesn’t work.
If I move the dialog construction into the showtimes_list function, everything works fine.

I thought that variables declared outside a function were global in context?

var dialog_list = $("<div></div>").dialog({
    autoOpen: false,
    modal: true,
    height: 300, width: 720,
});

function showtimes_list(sid){
    dialog_list.html("");
    $.get("ajax_showtimes.php?sid="+sid, function(data){
            dialog_list.html(data);
        }
    );

    dialog_list.dialog("open");
}

—Edit—

This is being called from an onClick to showtimes_list.

—Edit—

This is working:

function showtimes_list(sid){
    $("#stl").dialog("open");
    $("#stl").html("");
    $.get("ajax_showtimes.php?sid="+sid, function(data){
            $("#stl").html(data);
        }
    );    
}

$(function(){
    $('<div id="stl"></div>').appendTo(document.body).dialog({
        autoOpen: false,
        modal: true,
        height: 300, width: 720,
    });    
});
  • 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-15T06:05:44+00:00Added an answer on May 15, 2026 at 6:05 am

    Instead of creating a new empty div, add the div to the document, e.g.:

    <body>
       <div id="dialog">
          <div id="dialogContent"></div>
       </div>
    </body>
    

    Then, your script will become

    var dialog_list = $("#dialog").dialog({ });
    

    Then, when you want to change the HTML of that element, instead of changing the dialog itself, you’d want to change the dialogContent element:

    function showtimes_list(sid){    
         var content = $("#dialogContent");
         content.html("");
        $.get("ajax_showtimes.php?sid="+sid, function(data){
                content.html(data);
            }
        );
    
        dialog_list.dialog("open");
    }
    

    If you don’t want these empty divs in your HTML structure, you should add them to the body dynamically and use classes instead of ids.

    Edit: to answer your question as to why it doesn’t work when the dialog_list is outside the function, I’d imagine it has something to do with the generated html.

    When you call .dialog(), jQuery generates the following HTML:

    <div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-resizable">
       <div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">
          <span id="ui-dialog-title-dialog" class="ui-dialog-title">Dialog title</span>
          <a class="ui-dialog-titlebar-close ui-corner-all" href="#"><span class="ui-icon ui-icon-closethick">close</span></a>
       </div>
       <div style="height: 200px; min-height: 109px; width: auto;" class="ui-dialog-content ui-widget-content" id="dialog">
          <p>Dialog content goes here.</p>
       </div>
    </div>
    

    When this is outside of your function, it is called whenever it is encountered in the script… Then, in your function, you change that generated HTML. It’s been a while since I dynamically updated dialog content, but I ran into the same problem, and the generated HTML was the culprit. I think my solution was to, instead of the nested divs in my original answer, I created the dialog as you did (outside the function), and inside the function, you change the html of the ui-dialog-content

    For instance:

    function showtimes_list(sid){
        dialog_list.find('.ui-dialog-content').html("");
        $.get("ajax_showtimes.php?sid="+sid, function(data){
                dialog_list.find('.ui-dialog-content').html(data);
            }
        );
    
        dialog_list.dialog("open");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 498k
  • Answers 498k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You use a MethodBuilder to define methods. To define the… May 16, 2026 at 12:12 pm
  • Editorial Team
    Editorial Team added an answer It sounds like you've got an awful lot of abstraction… May 16, 2026 at 12:12 pm
  • Editorial Team
    Editorial Team added an answer As it turns out there is no method on the… May 16, 2026 at 12:12 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I want to create a jQuery dialog from HTML returned by an AJAX call.
I have a script that forces a download and I make a call to
i have a function call it: myFunction(A,B,C) I have onchange event in my option
How do I call Zedgraph's function masterPane.SetLayout() from Web C# Application? Basically i'm stuck
I've bound a function to a form submit button. I want the function to
I'm trying to use the jQuery BlockUI Plugin to block a jQuery dialog while
I'm trying to get an openfile dialog to show up on windows CE 6.0
What I am trying to accomplish is using jQuery UI dialog method from my
I'm making a simple remove link with an onClick event that brings up a
I am writing an Ajax application which uses a callback function to add a

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.