I have 2 simple pages.
Index contains a hyperlink with an anchor tag which with jquery has a function click defined.
The page also contains a DIV called “container”
The click function opens a dailog using .dialog()
The dialog page itself is a second page in which i try to close the dialog but this doesnt work.
Can you explain me why this is not working?
====== CODE FROM INDEX PAGE ===========
<script type="text/javascript">
$().ready(function () {
$("#LaunchModal").click(function () {
$.get(
"Home/RandomPopupView",
function (htmlResult) {
$("#RandomModal").remove(); //In case this is the second time they've requested the dialog.
$("#container").append(htmlResult);
$("#RandomModal").dialog();
}
);
return false; //To keep the default behavior of the anchor tag from occuring.
});
});
</script>
<a href="" id="LaunchModal">Launch Modal!</a>
<div id="container">
====== CODE FROM DIALOG PAGE ===========
<div id="RandomModal">
<script type="text/javascript">
$().ready(function () {
//TEST TRY TO CLOSE THE DIALOG DIV IMMEDIATELY FROM WITHINN THE DIV ITSELF
$("#RandomModal").dialog("close"); //CLOSE DOES NOT WORK
$("#submitModal").click(function () {
var SomeString = $("#SomeString").val()
$.post("/Home/RandomPopupViewPOST",
{
SomeString: SomeString
},
function (html) {
$("#RandomModal").empty();
$("#RandomModal").append(html);
});
});
});
</script>
</div>
=======================================
the get method doesn’t load a page you would need to load iframe to get ready event on second page to trigger
so I would us put your code in the main page and use live event
though I’m not sure thats the right solution either the more i read your code the more I don’t understand what your trying to do