An Intro to Backbone.js: Part 3 - Binding a Collection to a View

  • Contrived examples like this have a problem, where the code example is too complex compared to the very simple task, in this case keeping a HTML list populated with items from a JS object.

    I have used binding mechanisms in the Flex framework, which act in a similar way. The model object dispatches events which the view listens to and updates its own representation. In Flex the model object is often an "ArrayCollection," in this example, "Donuts." In Flex the view would often be some kind of "List" object, in this example, "DonutCollectionView."

    The Donut aspect of this example is the contrived bit. It's just a generic list. Donut could just be any Object that maps to some kind of HTML representation. DonutCollectionView could just be a CollectionView, that passes along that representation to a HTML list.

    The plumbing in this example is something I don't really want to write if I am using a framework. If I had to write it, I wouldn't write it like this. Am I misunderstanding something?