Answer the question
In order to leave comments, you need to log in
Please point out the flaws in the Backbone.js code?
I study Backbone.js, it comes with a creak. What can be improved in this simple example?
jsFiddle
Answer the question
In order to leave comments, you need to log in
In fact, the example is normal. Backbone was created for that, so that you would do everything yourself and how you want.
Unless I advise a puppet, it will ease your suffering from backbone.
render: function(person) {
var that = this;
this.$el.empty();
this.collection.each(function(person) {
var personView = new PersonView({model: person});
that.$el.append(personView.render().el);
});
return this;
}
render: function(person) {
this.$el.empty();
this.collection.each(function(person) {
var personView = new PersonView({model: person});
this.$el.append(personView.render().el);
}, this);
return this;
}
PersonView.prototype.render is called 2 times: 1 time in the constructor (don't do this) and once in the collection's render loop.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question