I have a button that, when clicked, loads an external page (the same domain) into a div and displays that div as a jQuery interface dialog box.
<div id="Dialog_box"></div> <script type="text/javascript"> $(function() { $("#Dialog_box").dialog({ autoOpen: false, modal: true, width: 500, height: 400, title: "Dialog", close: function(event, ui) { $("#Dialog_box").html(""); </script> <button onclick="openDialog();">Open Dialog</button>
The first time you press a button, a fine opens. After its closure, it will no longer return.
At first I made sure that it was actually closed by pressing the "X" button
$("#Dialog_box").dialog({ ... close: function(event, ui) { alert("Closed"); } });
And a warning was shown. Then I tried using my regular code, but didn’t load on the page
$("#Dialog_box").dialog('open');
At this point, the dialog will open and close properly without any problems. Although I do not think this is important, I even tried to separate the download and dialog commands
function openDialog() { $(document).ready(function() { $("#Dialog_box").load("dialog.php"); $("#Dialog_box").dialog('open'); }); }
The window will be displayed again for the first time, but will not appear after that.
My external file looks something like this:
<link type="text/css" href="path/to/style.css" rel="stylesheet" /> <script type="text/javascript" src="path/to/jquery.js"></script> <script type="text/javascript" src="path/to/jquery-ui.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#Submit_button").click(function() { </script> <form action=''> // Input fields <input type="button" id="Submit_button" /> </form>
Only to find out the problem, the problem arises, can I submit my form.
Why won't the dialog box open after I have loaded (and, as far as I know, unloaded) the page into it?