Take a look at this Model and View setup. Why is the indicated line not functioning as expected?
var app = app || {};
(function () {
app.CurrentUserView = Backbone.View.extend({
el: $('.avatar-container'),
template: ux.template('.avatar-container-hbs'),
initialize: function () {
this.model = new app.User();
this.model.fetch();
x=this.model;
//these two lines output expected values.
console.log(this.model);
console.log(this.model.toJSON());
this.render();
},
// Re-render the titles of the post item.
render: function () {
//this is the problematic line (empty)
this.$el.html(this.template(this.model.toJSON()));
return this;
}
});
})();
Model:
var app = app || {};
(function () {
'use strict';
app.User = Backbone.Model.extend({
url:'api/user.php'
});
})();