Some thoughts on Backbone.js

I've been working on, which consists of a Backbone.js application, with the server-side code using Node's Express framework.

After some fumbling around, I finally read the "Getting Started" section on, and Backbone is starting to make some sense. Backbone does make it possible to use a templating system to make a template like this:

    {{#if annotationMode}}
      <div class="onoffswitch onoffswitch-checked">
      <div class="onoffswitch">
And then manipulate that property in the render method of the Backbone.View:
    var MyView = Backbone.View.extend({
      render: function() {
          annotationMode: false

One thing I don't like about Backbone is that they encourage what they call "Bootstrapped Models". Which means, instead of loading the data with an XHR request, it's rendered by the back-end into the page's template, like this:

      var accounts = new Backbone.Collection;
      accounts.reset(<%= @accounts.to_json %>);
      var projects = new Backbone.Collection;
      projects.reset(<%= @projects.to_json(:collaborators => true) %>);

Using global variables like that introduces complexity and makes it awkward to use a module system like requirejs.