News for hackers. Stuff that matters.
Re:Backbone.js Tutorial - by noob for noobs by alexpeattie on Sunday January 30, 2011 @11:44AM (#2158385)
A very minor suggestion, but I think the last line (var appview = new AppView) is a little bit confusing on first reading - it's not immediately obvious that you're setting the variable to initiate the view... I've seen it written elsewhere like so:

  window.App = new AppView
which I think is a good idiom.
Re:Backbone.js Tutorial - by noob for noobs by catshirt on Sunday January 30, 2011 @12:42PM (#2158528)
fwiw these are not the same thing in this context. the example doesn't actually declare appview in the window namespace, possibly intentionally. i agree it's a bit unclear though.
Re:Backbone.js Tutorial - by noob for noobs by alexpeattie on Sunday January 30, 2011 @01:04PM (#2158596)
Of course you're right, they're not identical, but I don't think there's any practical difference between them here - they both initiate the view; but using the window namespace seems more readable, and is an established idiom. Maybe it is intentional, but I don't think so?
Re:Backbone.js Tutorial - by noob for noobs by bluesmoon on Sunday January 30, 2011 @03:01PM (#2158977)
but that would assume a browser, right?
Re:Backbone.js Tutorial - by noob for noobs by alexpeattie on Sunday January 30, 2011 @03:53PM (#2159143)
It does, but as catshirt says, that's probably reasonable. Especially as jQuery assumes a browser (and relies on the window namespace) too - so it wouldn't be suitable for a browserless environment anyway...
Re:Backbone.js Tutorial - by noob for noobs by catshirt on Sunday January 30, 2011 @03:24PM (#2159047)
i think for a backbone view it's a fine assumption. i didn't mean to be nitpicky, just an fyi for anyone reading unaware.