title: onYouTubeIframeAPIReady inside jQuery(document).ready
body: <p>What I want to do is:</p>
  
  <ol>
  <li>Wait for the document to render;</li>
  <li>When YouTube iframe api is ready, initialize my custom function and pass the <code>YT</code> object to it so I can build the player from inside.</li>
  </ol>
  
  <p>This is what I have done so far. It works but I have feeling something is very wrong. I am not sure it should be done this way. </p>
  
  <pre><code>jQuery.getScript("http://www.youtube.com/iframe_api"); // load YT api
  
  jQuery(document).ready(function() {
    onYouTubeIframeAPIReady = function() {
      new my_custom_function().init(YT); // init my function and pass YT object
    };
  });
  </code></pre>
  
  <p>I'd appreciate it if someone can clarify what's the best way to do this. I do really need to build the players from inside <code>my_custom_function()</code>.</p>