I'm trying to call loadPhotos, but I get an error saying that loadPhotos is not defined. I tried this.loadPhotos();
but then I get an error saying that the object doesn't have such a method. I'm pretty new at this and still trying to figure out what has access to what and such, and I'd greatly appreciate if someone could point me in the right direction. What am I doing wrong?
Here's my code:
Album = Backbone.Collection.extend ({
model: Photo,
url: "/api/",
albumName: "",
initialize: function(models, options){
options || (options = {});
if (options.title) {
this.albumName = options.title;
};
$.ajax({
type: "GET",
url: this.url,
data: "album=" + this.albumName,
dataType: "json",
success: function(data){
console.log(data);
loadPhotos(data); // <<< the problem is right here
},
error: function(jqXHR, textStatus, errorThrown){
console.log("FETCH FAILED: " + errorThrown);
}
});
},
loadPhotos: function(filenames){
for (var i = 0; i < filenames.length; i++ ){
var photo = new Photo( {fileurl: filenames[i] });
var photoView = new PhotoView( { model: photo} );
this.add(photo);
}
}
});