Created
August 31, 2012 03:41
-
-
Save Fitzsimmons/3548815 to your computer and use it in GitHub Desktop.
Passing context in javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var that = this; | |
| this.player.on("audio-ended", function() { | |
| that.next(); | |
| }); | |
| //-------VERSUS----------- | |
| this.player.on("audio-ended", function() { | |
| this.next(); | |
| }, this); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Without explicitly specifying the context in some way, this callback gets called in the context of the Player object, instead of the "current" object, which is the Playlist.