Skip to content

Instantly share code, notes, and snippets.

@Fitzsimmons
Created August 31, 2012 03:41
Show Gist options
  • Select an option

  • Save Fitzsimmons/3548815 to your computer and use it in GitHub Desktop.

Select an option

Save Fitzsimmons/3548815 to your computer and use it in GitHub Desktop.
Passing context in javascript
var that = this;
this.player.on("audio-ended", function() {
that.next();
});
//-------VERSUS-----------
this.player.on("audio-ended", function() {
this.next();
}, this);
@Fitzsimmons
Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment