title: Javascript Button OnClick Callback
body: <p>I'm trying to emulate the confirm() functionality with my own styled modal. I have a function with a callback:</p>
  
  <pre><code>function confirmChanges(callback) {
  
      function clickOkay() {
          callback(true);
      }
  
      function clickCancel() {
          callback(false);
      }
  }
  </code></pre>
  
  <p>This section is where I need the confirmChanges function to return true/false:</p>
  
  <pre><code>if (unsavedChanges == true) {
      j$('.confirm').showModal();
      if (confirmChanges(function(result) {return result;})) 
      {
          // Do stuff and return true
      } 
      else 
      {
          return false;
      }
  }
  </code></pre>
  
  <p>Here's my HTML I'm using for the modal:</p>
  
  <pre><code>&lt;div class="warningpop confirm"&gt;
  
      &lt;h3&gt;Unsaved Changes!&lt;/h3&gt;                         
      &lt;a id="modalContinue" value="Continue" onclick="clickOkay();"/&gt;  
      &lt;a id="modalCancel" value="Cancel" onclick="clickCancel();"/&gt;   
  
  &lt;/div&gt;
  </code></pre>
  
  <p>However when I click the buttons in the dialog I get the error "clickCancel() / clickOkay() is not defined". </p>
  
  <p>How can I fix it so that it returns true or false depending on the button clicked?</p>