Skip to content

Comment on An Intro to Backbone.js: Part 3 - Binding a Collection to a Viewparent

Comments

Nope -- you're not misunderstanding anything ... you probably wouldn't be writing plumbing like this if you were working on a real app, instead of a contrived example.

You're absolutely right that it's vastly overcomplicated for the task that needs to be accomplished here.

Do you have any better examples? I'd like to learn more about where this would fit in a real app.

Sure ... some of these have source code available, and some do not.

http://documentcloud.github.com/backbone/#examples

In particular the TileMill example (launched yesterday) is a really sophisticated map editing application, with annotated source code available, here:

http://tilemill.com/docs/models.html

(Use "Jump To", at the top right, to get around)

If you'd like to get your feet wet, and play around with models a little, try visiting http://www.documentcloud.org/public

Pop open a JS console, and try...

    Documents.length

    Documents.first().set({title: "Changing the Title Syncs the View"})

    Documents.first().set({description: "Lorem Ipsum Dolor Sit Amet"})
... then click on "Annotated Documents", at the top left, go back to the console, and try:
    Documents.first().notes.fetch()

    Documents.first().notes.first().set({content: "Writing a Note."})
You get the idea.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.