Articulated Vertebrae

minimalist Backbone.js examples

These are different Backbone.js apps I wrote, for educational purposes.

program Router? View? Model? Collection? notes
justaview . view . . bare minimum 'hello world' program, using a BB view
justarouter . view . . page showing #fragment inner pages, using a BB router. and colors.
helloworld router view . . bare minimum BB view and router working together
echo . . model . a small app using nothing from BB but a Model class. Not even routers or views! Everything else done in regular html, js and jQuery.
jrivers . . model . a model-only page that's a bit more complex. and fun.
carnac router view model collection It's mostly a simplified version of lostsoul's example app. Took out Ajax and the need for a server. Also took out jQuery.template and the nocss thing.

The juicy info is in the source comments in the .html files. I'm assuming that you're a web programmer familiar with current JavaScript, and with jQuery, as I was, too, when I started. Backbone also uses underscore.js .

These programs are also somewhat rough - for instance, attributes without quotes, <html> tags omitted, all tricks you can get away with on all browsers, although it's considered sloppy. This was done to simplify the files and avoid distractions. You can copy my bad habits or not.

These examples came about because I had to learn Backbone.js for my job. From the start, I had a problem with it; why do we need all this complexity? All of the examples, even the simple ones, seemed to have dozens of files and several other technologies, some that I'd never seen before, often with some sort of server application in whichever language/technolgy the author wrote in. These are fine for the project they were intended for; just not good for getting up to speed quickly with Backbone.js.

Meanwhile, Backbone.js, as of the start of 2013, can be described as 'testy', meaning, you have to test after each little change you make to be sure you didn't break anything. My attempts to start from an empty file and make a BB app were all failures. Unless I can type in a 'hello world' program from memory, or set up a trivial example, I don't really believe that I 'know' a system.

Some of these are based (loosely) on the 'very simple backbone application' by lostsoul@beyondtheclouds.net. Indeed, I made it simpler. But without lostsoul, I would have been a lost soul as most of my attempts to write BB scripts from scratch did nothing.