Live data from Hacker News

Announcing Backbone.js: Models, Collections and Views in 2.4kb

documentcloud.github.com

1–10 of 62 posts

Re: Announcing Backbone.js: Models, Collections and Views in 2.4kb

#2
I got a sneak preview of this yesterday. Having worked on a couple of large-ish JavaScript UI projects this is the kind of thing that people invent over and over again without ever distilling a minimal, extensible, and reusable set of functionality, it's either too application specific or heavily embedded in a larger framework (Cappuccino/SproutCore). MooTools+Backbone.js and/or jQuery+Backbone.js sounds like a killer combo to me!

Re: Announcing Backbone.js: Models, Collections and Views in 2.4kb

#3
Key point of Backbone.js: This is for designing web apps, not just a web page. When you have multiples of the anything on a page, it's time to move to separating out your views from your models, and Backbone.js is perfect for this sort of transformation. Even better if you start with Backbone.js. And Backbone.js is a minimal set of functionality to get this done.

We use Backbone.js at DocumentCloud for our document workspace. It took a few weeks to pull out all the pieces, but we rely on the JavaScript MVC that Backbone gives us for the entire workspace. (That too will go open-source, someday soon enough.)

I am personally planning on integrating Backbone into NewsBlur, an RSS feed reader, which currently has an ad-hoc model system. Backbone would give it the ability to update stories and feeds without having to remember where all of the stories and feeds are on the page.

Anyway, Backbone takes a bit of getting used to, but it is fairly easy to read the annotated source to see exactly what's happening. And once you do learn the Backbone.js conventions, hard problems become much easier on the front-end.

Re: Announcing Backbone.js: Models, Collections and Views in 2.4kb

#7
Sorry, I'm a little late to the party with respect to javascript. Could someone please explain to me what this means in english?

Backbone supplies structure to JavaScript-heavy applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing application over a RESTful JSON interface.

Re: Announcing Backbone.js: Models, Collections and Views in 2.4kb

#9
post #7

Sorry, I'm a little late to the party with respect to javascript. Could someone please explain to me what this means in english? Backbone supplies structure to JavaScript-heavy applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing application over a RESTful JSON interfa…

Yep -- let's dejargonize that for you:

"key-value binding and custom events": When a model changes its state, other JavaScript objects can listen for that change and be notified. It's the usual inversion-of-control pattern, but especially crucial for models and views. A model has no business knowing about what views may or may not currently be present in the UI. Instead, the views listen to changes in the model, and update themselves accordingly.

"rich API of enumerable functions": JavaScript arrays are pretty feature-poor, at least in terms of things that will work cross-browser. Backbone collections include all of these handy functions for working with your data:

http://documentcloud.github.com/backbone/#Collection-Undersc...

"views with declarative event handling": Instead of creating a mess of nested jQuery "bind" or "delegate" calls, it's nice to just declare what elements in a view should be hooked up to specific callbacks:

http://documentcloud.github.com/backbone/#View-handleEvents

"RESTful JSON interface": The persistence strategy for Backbone can be swapped out for something different (Websockets, Local Storage, CouchDB), but the default is to fire off a standard JSON Ajax call when you call "model.save()"...

Hope that helps a little.

Re: Announcing Backbone.js: Models, Collections and Views in 2.4kb

#10
post #7

Sorry, I'm a little late to the party with respect to javascript. Could someone please explain to me what this means in english? Backbone supplies structure to JavaScript-heavy applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing application over a RESTful JSON interfa…

It means that Backbone provides a way to cleanly separate your model/data from your presentation such that your model is concerned with synchronizing state with a server and the view is concerned with listening to changes in that model via data binding.
Post reply on HN