I have a simple music app written using backbone.js. I'm having trouble with the code below in one of my models:
MyApp.Models.Program = Backbone.Model.extend({
toPlaylist: function(options, callback) {
console.log("Converting program to playlist");
var self = this;
console.log(self.get('name'));
this.stationHasLicense(function (licensedStation) {
console.log(self.get('name')); // Uncaught TypeError: Cannot call method 'get' of undefined
// bunch of other logic
});
},
});
The first self.get works fine. The second self.get in the stationHasLicense callback, however, throws the error. I'm using var self = this all over other areas of my app to keep scope, but I'm not sure why this instance is failing.