0
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
4
  • 1
    Where did you find this? Commented Jun 25, 2014 at 11:45
  • 1
    el: is a label, the return value of $('body') is not used --> this is just nonsense. Commented Jun 25, 2014 at 11:48
  • If el is inside initialize function how could we use it out side to set view?? Commented Jun 25, 2014 at 11:51
  • @SergioTulentsev reviewing one commercial project, can't say details due to privacy reasons Commented Jun 25, 2014 at 14:19

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.