View stunning SlideShares in full-screen with the new iOS app!Introducing SlideShare for AndroidExplore all your favorite topics in the SlideShare appGet the SlideShare app to Save for Later — even offline
View stunning SlideShares in full-screen with the new Android app!View stunning SlideShares in full-screen with the new iOS app!
Backbone.js Oct 2010, DocumentCloud(Underscore.js, CoffeeScript)
What does it do?“Backbone.js gives structure to web applicationsby providing models with key-value binding andcustom events, collections with a rich API ofenumerable functions,views with declarativeevent handling, and connects it all to yourexisting API over a RESTful JSON interface.”
Other• History – a global router (per frame) to handle hashchange events or pushState – matchs the appropriate route, and trigger callbacks• Backbone.sync – method: the CRUD method – model: the model to be saved (or collection to be read) – options: success and error callbacks, and all other jQuery request options
Catalog of Events• "add" (model, collection) — when a model is added to a collection.• "remove" (model, collection) — when a model is removed from a collection.• "reset" (collection) — when the collections entire contents have been replaced.• "change" (model, options) — when a models attributes have changed.• "change:[attribute]" (model, value, options) — when a specific attribute has been updated.• "destroy" (model, collection) — when a model is destroyed.• "sync" (model, collection) — triggers whenever a model has been successfully synced to the server.• "error" (model, collection) — when a models validation fails, or a save call fails on the server.• "route:[name]" (router) — when one of a routers routes has matched.• "all" — this special event fires for any triggered event, passing the event name as the first argument.