Creating my own callbacks
<p>I have a page with some jQuery, and a separate non-jQuery function.</p>

<p>Currently my function runs on $(document).ready, but I want to call a jQuery function as soon as my function is finished. I can pass my function as a callback to any jQuery function, but how can I set things up the other way round?</p>

<p>So I would ideally like to know how to create a function foo that will take care of this for me:</p>

<pre><code>$(document).ready(function() {
  foo(myfunction(), $(bar).something);
}
</code></pre>

<p>or how to extend an existing function to handle callbacks. Thanks.</p>
