title: How to pass back modal dialog confirmation result to calling function?
body: <p>I've added a jquery UI dialog to an mvc page. After the dialog is opened I need to catch the <code>bool</code> values if the dialog is <em>dismissed</em> or <em>confirmed</em>.</p>
  <p>So far I have tried to add a call back as mentioned in another answer, but I'm not sure how to pass that value back to the <code>$('#escalation').on('click', '.delete', function (evt)</code> so that I may perform a redirect if true.</p>
  <p><strong>Question:</strong></p>
  <p>How can I pass back a bool value to calling function from Jquery UI modal dialog?</p>
  <p><strong>Pseudo code:</strong></p>
  <p>This is my intended flow of execution for the below fuctions:</p>
  <blockquote>
  <p>1.Call dialog open on a button click. - (working)</p>
  <p>2.Pass back true or false depending on if the user selected 'ok' or 'cancel' in the modal dialog.</p>
  <p>3.Close the dialog if the returned result to the button click event is false. Otherwise call <code>window.location.href = RedirectTo;</code> code.</p>
  </blockquote>
  <p><strong>Code:</strong></p>
  <p>Dialog markup -</p>
  <pre><code>                            &lt;div id=&quot;dialog-confirm&quot; title=&quot;Delete Selected Record?&quot;&gt;
                                  &lt;p&gt;&lt;span class=&quot;ui-icon ui-icon-alert&quot; style=&quot;float:left; margin:0 7px 20px 0;&quot;&gt;&lt;/span&gt;This record will be permanently deleted.&lt;/p&gt; &lt;p&gt;Are you sure?&lt;/p&gt;
                              &lt;/div&gt;
  </code></pre>
  <p>Jquery scripts -</p>
  <pre><code>&lt;script&gt;
      var baseUri = '@Url.Content(&quot;~&quot;)';
  
      $(document).ready(function () {
          $('#escalation').DataTable({
              &quot;order&quot;: [[6, &quot;desc&quot;]]
          });
  
  
          $('#escalation').on('click', '.delete', function (evt) {
              var cell = $(evt.target).closest(&quot;tr&quot;).children().first();
              var EscalationID = cell.text();
              var RedirectTo = baseUri + &quot;/EscalationHistory/DeleteEscalation?EscalationID=&quot; + EscalationID;
  
  
              ////open dialog 
              evt.preventDefault();
              $(&quot;#dialog-confirm&quot;).dialog(&quot;open&quot;);
  
              //Need to call this code if the dialog result callback equals true
              window.location.href = RedirectTo;
  
             //Otherwise do nothing..close dialog
           
          });
  
  
          //Dialog opened here, not sure how to pass back the boolean values
          //to the delete click function above
          $(&quot;#dialog-confirm&quot;).dialog({
              autoOpen: false,
              modal: true,
              buttons: {
                  &quot;Confirm&quot;: function () {
                      callback(true);
                  },
                  &quot;Cancel&quot;: function () {
                      $(this).dialog(&quot;close&quot;);
                      callback(false);
                  }
              }
          });
  
        
      });
  &lt;/script&gt;
  </code></pre>