Not able to close Dialog from parent dialog reference

Posted by coffeeaddict on Stack Overflow See other posts from Stack Overflow or by coffeeaddict
Published on 2010-04-15T14:33:42Z Indexed on 2010/04/15 14:43 UTC
Read the original article Hit count: 358

Filed under:
|

In the dialog content, I have this:

    <script type="text/javascript">
        $(function() {
            $("#cancel").click(function(o) {
            alert(parent.$('#dialog'));
                parent.$("#dialog").dialog("close");
                o.preventDefault();
            });
        });
    </script>

and also tried this:

    <script type="text/javascript">
        $(function() {
            $("#cancel").click(function(o) {
                $(this).closest("#dialog").dialog("close");
                o.preventDefault();
            });
        });
    </script>

<a id="cancel" href="#"><img src="images/cancelBtn.gif" /></a> 

This code again is the content of my dialog. When the user clicks the hyperlink I'm trying to close the parent dialog (the dialog that this content is in) but it's not doing anything. I know that the alert gets hit and that there is an object for parent.$('#dialog'); so not sure why it won't close the parent dialog

© Stack Overflow or respective owner

Related posts about jquery-ui

Related posts about jQuery