Combining function and callback parameter to create new function
<p>I have a wrapper around the jQuery animate function, which accepts a callback parameter to fire after the animation is completed. I want to "build" that callback by combining a user-passed callback and internal code. For example, the user passes <code>function Foo</code> as his callback. I want the actual callback to be <code>function Foo(); function Bar();</code> where <code>function Bar()</code> is internally defined. Here's an example of what I'm trying to achieve: </p>

<pre><code>MainSubController.prototype.changeMain = function($newMain, subWinCallback) {

$mainWinCpy.animatePositionChange(lastSubWinPos, this.subWinSize, 
        function() {self.subWins.push($mainWinCpy); subWinCallback(); });
}
</code></pre>

<p>I think I could do it by building an intermediary partial function, but I'm not sure, and if I could, I don't know how to go about doing it.  </p>

<p>Edit: The problem with the above code is that subWinCallback is not executed, or, it's not executing at the right time. </p>
