News for hackers. Stuff that matters.
Re:Step by step from jQuery to Backbone by jashkenas on Monday July 23, 2012 @11:56AM (#4281580)
You're quite correct -- any "trivial" tutorial example will always be better off written without an external dependency. But we're not using libraries to help make writing 10 lines of jQuery easier -- we're using libraries to help write JavaScript applications. The idea is that Backbone will end up helping your write far fewer lines of JS in your real-world app, because instead of having to manually:

    updateTitle: function(id, title) {
      var doc = window.myApp.documents[id];
      $('.document-' + id + ' .title').text(title);
      if (localStorageAdapter.get(".doc-" + id)) {
        localStorageAdapter.set("document", ".doc-" + id, "title", title); 
      }
      var details = $(".document- " + id + " .details");
      if (details.length) {
        details.find(".doc-title").text(title);
      }
      ... and so on, and so forth ...
    }
You have a convenient way to manipulate your data and have your UI react:

    Documents.get(id).set({title: "Don Quixote"});
... at least, that's the hope.

There are no comments on this comment yet.