title: JavaScript runtime error: cannot call methods on dialog prior to initialization; attempted to call method 'close'"
body: <p>Error I get running the below code block: "0x800a139e - JavaScript runtime error: cannot call methods on dialog prior to initialization; attempted to call method 'close'".
  Failing at the statement: $(this).dialog("close");</p>
  
  <pre><code>function DeleteReport(reportTitle, reportId) {
      reportIdToDelete = reportId;
  
      var buttons = [
          '&lt;button id="btnYes" class="modalbtn" onclick="ConfirmDeleteReport();"&gt;Yes&lt;/button&gt;',
          '&lt;button id="btnNo" class="modalbtn" onclick="$.modal.close();"&gt;No&lt;/button&gt;'
      ];
  
      ShowMessage('Are you sure you want to delete Report:' + reportTitle + '?&lt;br&gt;This action cannot be undone.', '', buttons);
  }   
  
  function ConfirmDeleteReport() {
      $.ajax({
          url: "/Report/DeleteReport",
          data: { reportId: reportIdToDelete },
          type: 'Get',
          success: function (data) {
              if (data.codeResult == 1) {
                  $(this).dialog("close");
                  window.location.reload(true);
              }
              else {
                  ShowMessage(data["message"], "");
              }
          },
          error: function (request, status, error) {
              ShowMessage("Error while proccessing ..", "Error, Report Not Deleted");
          }
      });
  }
  </code></pre>