Hacker News new | ask | show | jobs
by misterm 5722 days ago
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.

2 comments

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.

Yes it does. Thank you for the explanation.

For anyone unclear about REST, try this: http://tomayko.com/writings/rest-to-my-wife

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.