Being new to Backbone.js, just wanted to clarify the correct way to go about this simple task.
Developing a web app, almost always, you\'ll have user accounts, where use
There is not any reason to feel forced to declare a Collection
for every Model
your App has. It is very common to have Models without Collection associated.
// code simplified and not tested
App.CurrentUser = Backbone.Model.extend({
url: "http://myapp.com/session.json"
});
App.CurrentUserView = Backbone.View.extend({
el: "#user-info",
render: function(){
this.$el.html( "" + this.model.get( "name" ) + "
" );
}
});
var currentUser = new App.CurrentUser();
currentUser.fetch();
var currentUserView = new App.CurrentUserView()({ model: currentUser });
currentUserView.render();