Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading omitted code #14

Closed
kostasx opened this issue Aug 15, 2015 · 1 comment
Closed

Misleading omitted code #14

kostasx opened this issue Aug 15, 2015 · 1 comment
Labels

Comments

@kostasx
Copy link

kostasx commented Aug 15, 2015

In the Event Binding section http://rapidprototypingwithjs.com/#event-binding, the 3rd code sample:

...
var appleView = Backbone.View.extend({
this.model = new (Backbone.Model.extend({}));
this.model.bind('change', this.render, this);
this.bind('spinner',this.showSpinner, this);
},

presents and erroneous and quite misleading code fragment. Instead, I would suggest that the initialize function should not be omitted for clarity purposes:

...
var appleView = Backbone.View.extend({
initialize: function(){
this.model = new (Backbone.Model.extend({}));
this.model.bind('change', this.render, this);
this.bind('spinner',this.showSpinner, this);
},
...

Of course, one can see the final code a couple of lines below, but for the sake of code readability it’s better that this line is included.

Thank you for a great resource!

@azat-co azat-co added the bug label Oct 21, 2015
@azat-co
Copy link
Owner

azat-co commented Nov 19, 2015

fixed in new book Fullstack JavaScript

@azat-co azat-co closed this as completed Nov 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants