title: Closing a jQuery dialog
body: <p>I'm currently working on loading a dialog with a View.  This View handles both Insert and Edit for products being purchased.</p>
  
  <p>The issue I'm coming across is when I save my product, I need to close the dialog and refresh a grid that was on the original page.  When I try to do so, I'm trying to find the dialog in my parent and trigger the close event.  So far I've been ineffective in finding the dialog in the parent.  I have been able to find the grid and force it's refresh.</p>
  
  <p>My question is, is there a way to trigger the closing from within the dialog?  Btw, I'm not sure if this is part of the issue or not, but I'm using a full View for my dialog and not a Partial View.</p>
  
  <p>Any help would be appreciated.  Thanks.</p>
  
  <p>Kindest Regards,
  Chad</p>
  
  <p>Edit: Here is my code.</p>
  
  <p>View (parent page)</p>
  
  <pre><code>...
  &lt;div id="divPOProduct"&gt;
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
      var selectedIds = [];
  
      $(document).ready(function () {
              $("#divPOProduct").dialog({
                  height: 500,
                  width: 700,
                  modal: true,
                  autoOpen: false,
                  draggable: false,
                  resizable: false,
                  open: function () { },
                  close: function (event, target) {
                          alert("Here");
                          return false;
                  }
              });
  
     //"Add" button
              $("#add-poproduct").click(function (e) {
                  e.preventDefault();
  
                  var link = '@(Url.Action("POProductAddPopup", "PurchaseOrder", new { purchaseOrderId = Model.Id }))';
                  //OpenWindow(link, 600, 500, true);
  
                  $("#divPOProduct").load(link);
                  $("#divPOProduct").dialog("open");
  
  
                  return false;
              });
  
  ...
  </code></pre>
  
  <p>View (dialog)</p>
  
  <pre><code>$("#save").click(function (e) {
          var validationTest = CheckValidation();
  
          if (validationTest) {
              var model = {
                  ...
              };
              $.getJSON('@Url.Action("SavePurchaseOrderProduct", "PurchaseOrder")', model, function (result) {
                  if (result) {
                      //$(this).closest('.ui-dialog-content').dialog('close')
                      window.parent.$("divPOProduct").dialog("close");
                      //$(window.parent).find("divPOProduct").dialog("close");
                  }
              });
              return false;
          }
      });
  });
  </code></pre>
  
  <p>The three attempts you will see in the if statement for the result are what I have tried thus far.  I can find the parent now and the div, but not the dialog.  Btw, all that returns from result is true/false.</p>