title: Javascript/Jquery Callback for Fancybox Yes No Confirm
body: <p>I'm trying to implement a fancy Yes No confirm and I'm having problems getting the callback to work as needed. The example below is using <a href="http://fancyapps.com/fancybox/#docs" rel="nofollow">Fancybox v2</a>.</p>
  
  <p>The problem with the code below is that the function "do_something" is being call when <code>HREF</code> "Test" is clicked and not being called when the user clicks <code>#fancyConfirm_ok</code>.</p>
  
  <pre><code>function fancyConfirm(msg,callback) {
      var ret;
      jQuery.fancybox({
          'modal' : true,
          'content' : "&lt;div style=\"margin:1px;width:240px;\"&gt;"+msg+"&lt;div style=\"text-align:right;margin-top:10px;\"&gt;&lt;input id=\"fancyconfirm_cancel\" style=\"margin:3px;padding:0px;\" type=\"button\" value=\"Cancel\"&gt;&lt;input id=\"fancyConfirm_ok\" style=\"margin:3px;padding:0px;\" type=\"button\" value=\"Ok\"&gt;&lt;/div&gt;&lt;/div&gt;",
          'afterShow' : function() {
              jQuery("#fancyconfirm_cancel").click(function() {
                  ret = false;
                  //jQuery.fancybox.close();
                  $.fancybox.close();
              })
              jQuery("#fancyConfirm_ok").click(function() {
                  ret = true;
                  jQuery.fancybox.close();
              })
          },
          'afterClose' : function() { 
              if (typeof callback == 'function'){ 
                  callback.call(this, ret); 
              } else {
                  var callback_type = typeof callback;
                  alert(callback_type);
              }
          }
      });
  }
  &lt;a href="#" onclick="fancyConfirm('Are you sure you want to delete?',  do_something('a', 'b') );return false;"&gt;Test&lt;/a&gt;
  </code></pre>