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?
asked Jun 25, 2014 at 11:44
setec
16.2k3 gold badges39 silver badges51 bronze badges
1 Answer 1
It is valid syntax, but does for sure not do what you might expect. Here, it's just nonsense.
answered Jun 25, 2014 at 11:48
Bergi
671k162 gold badges1k silver badges1.5k bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js
el:is a label, the return value of$('body')is not used --> this is just nonsense.