title: jQuery - how to set callbacks to parent page in a popup
body: <p>When i open a popup, i want to be able to set few callbacks that the popup can call. 
  So basically i'd have two pages with code like this:</p>
  
  <pre><code>*****popup.html*******
  var callBack;
  function OnSaveClick()
  {
    if (callBack)
       callBack();
  }
  
  **********************************************
  ********popupOpener.html*************
  function callBackHandler()
  {
     //some code here
  }
  function OpenPopup()
  {
     var p = window.open("popup.html");
     p.callBack = callBackHandler;
     return false;
  }
  </code></pre>
  
  <p>The problem with this is that var callBack gets reset when the DOM of popup.html loads and it doesn't load until OpenPopup() on the opener completes.
  So the next best thing would be to set the callBack in the ready event of popup.html. But i want to be able to attach an event handler to the ready event of popup.html in popupOpener.html.
  So the OpenPopup function would now look something like this:</p>
  
  <pre><code>var p;
  function OpenPopup()
  {
    p = window.open("popup.html");
    $(p).ready(hookCallBack)      //doesn't work
    //or $(p.document).ready(hookCallBack)  //doesn't work
    return false;
  }
  function hookCallBack()
  {
    p.callBack = callBackHandler;
  }
  </code></pre>
  
  <p>But hookCallBack() executes immediately after $(p).ready(hookCallBack) and NOT when the DOM of popup.html is ready. Is there any other way to do this?</p>