开发者

Combining function and callback parameter to create new function

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 function Foo as his callback. I want the actual callback to be function Foo(); function Bar(); where function Bar() is internally defined. Here's an example of what I'm trying to achieve:

MainSubController.prototype.开发者_开发知识库changeMain = function($newMain, subWinCallback) {

$mainWinCpy.animatePositionChange(lastSubWinPos, this.subWinSize, 
        function() {self.subWins.push($mainWinCpy); subWinCallback(); });
}

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.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜