I have a user model, each user has an artist and every artist has several albums. I'm trying to render a view to show a user profile. When I try to render the view I get the following error:
Uncaught ReferenceError: albums is not defined
(anonymous function) b.template.c underscore-min.js:30
Backbone.View.extend.render profile.js:13
Backbone.Router.extend.profile router.js:62
...
It seems to be I'm not passing an album object to the template but I'm not using any album variable in that template, nor in the view. Here is the code for both:
View:
headerT = require('text!templates/user/profile_header.html');
profileT = require('text!templates/user/profile.html');
var profilesView = Backbone.View.extend({
el: $('#main-container'),
initialize: function(){
this.template = _.template(profileT);
this.artist = this.model.get('artist');
},
render: function(){
$(this.el).html(this.template({
current_user: app.current_user,
user: this.model.toJSON(),
artist: this.artist.toJSON(),
}));
return this;
},
});
Template:
<div class="row">
<div class="grid_3">
<img src="<%=user.pict%>" class="frame" alt="">
<span class="title">Username – <strong><%=user.username%></strong></span>
<%if(current_user!=undefined && (current_user.get('is_admin') == true || current_user.get('id') == user.id)){%>
<span class="title"><span class="icon user"></span> <a href="#/editProfile/">Edit Profile</a></span>
<%}%>
<%if(artist.active==true){%>
<div><a href="#/artistProfile/">Go to Artist Profile</a></div>
<%}%>
<div class="separator"></div>
</div>
<div class="clear"></div>
</div>