title: pass value/variable from fancybox iframe to parent
body: <p>I'am trying to pass a variable/ value from the fancybox iframe to the parent window without success.</p>
  
  <p>Fancybox is launched from a link with </p>
  
  <pre><code>   class="fancybox fancybox.iframe"
  </code></pre>
  
  <p>My code in the fancybox.iframe is:</p>
  
  <pre><code>$(document).ready(function(){
     $('.insert_single').click(function(){
      var test =  $('.members_body').find('{row.U_USERNAME}');
      setTimeout(function(){ parent.$.fancybox.close();},300);return true;
  
     });
  });
  </code></pre>
  
  <p>Where '{row.U_USERNAME}' is the username to find in the iframe.</p>
  
  <p>Then, in the parent there's the following code:</p>
  
  <pre><code> $(document).ready(function(){
   $('.fancybox').fancybox(
  
    {
  openEffect:'fade',
  openSpeed:500,
  
  
      afterClose: function(){
      alert($(".fancybox-iframe").contents().find(test)); 
      $('#form input[name=username]').val()(test);return false;
      }
  }                   
  
    );
   });
  </code></pre>
  
  <p>But when the fancybox is closed, there's no alert showing up with the variable "test", nor the variable is showing up as a value or as a text in the input field of the form.</p>
  
  <p>I've read and tried various solutions found here on stackoverflow without success.</p>
  
  <p>Thanks in advance for helping</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here's an <a href="http://jsfiddle.net/NXY7Y/9/" rel="nofollow">Example</a></p>