Reputation: 16090
View = Backbone.View.extend({
initialize: function() {
el: $('body');
this.template = "<div></div>";
this.model = new Model;
this.render();
}
)
I've found this code in one project, and was puzzled by el: $('body');
inside of the initialize code.
At first i thought it's just typo, and it had to be
View = Backbone.View.extend({
el: $('body'),
initialize: function() {
this.template = "<div></div>";
this.model = new Model;
this.render();
}
)
But then i've found it in a few another files.
Is it some kind of 'hacky' way to set el
or just nonsense?
Upvotes: 0
Views: 68
Reputation: 664217
It is valid syntax, but does for sure not do what you might expect. Here, it's just nonsense.
Upvotes: 1