locked
closing a jquery dialog window RRS feed

  • Question

  • User1575314614 posted

    So I have a link on a page that opens a modal dialog that contains another asp.net page.  That page will accept some user input and then process a postback.  I then want to close the modal window without the user needing to click on anything.  My first thought was to just redirect the content of that window to a generic web page that just contains a script that closes the window.  That way I can use this page for multiple uses, but I can't seem to figure out a script that will close it.  Any help would be greatly appreciated.

    Here's how I open the dialog

    <script type="text/javascript">
     $(function () {
       $('a.mDialog').click(function (e) {
         e.preventDefault();
         var $this = $(this);
         var horizontalPadding = 30;
         var verticalPadding = 30;
         $('<iframe id="externalPage" class="externalPage" src="' + this.href + '" />').dialog({
           title: ($this.attr('title')) ? $this.attr('title') : 'Dialog Title',
           autoOpen: true,
           width: 800,
           height: 500,
           modal: true,
           resizable: false,
           autoResize: true,
           overlay: {
             opacity: 0.5,
             background: "black"
           }
         }).width(800 - horizontalPadding).height(500 - verticalPadding);
       });
     });
    </script>
    
    <a href="addPerson.aspx" class="mDialog" title="Add Person">add person</a>
    
    
    
    
    


    Monday, July 12, 2010 10:32 AM

Answers

  • User1575314614 posted

    nevermind.  figured it out.  just used parent.location.reload();


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 12, 2010 2:34 PM

All replies

  • User1575314614 posted

    nevermind.  figured it out.  just used parent.location.reload();


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 12, 2010 2:34 PM
  • User-768391503 posted

    Reloading the page to get rid of it seems pretty extreme.

    You could just do

    $("selector").dialog("close");

    Eric

    Monday, July 12, 2010 2:52 PM