![](https://s3.amazonaws.com/media-p.slid.es/uploads/66414/images/1435416/backbone.png)
Models and Views
Model
|
View
|
Collections
var Books = Backbone.Collection.extend({
url: '/books'
});
GET /books/ .... collection.fetch();
POST /books/ .... collection.create();
GET /books/1 ... model.fetch();
PUT /books/1 ... model.save();
DEL /books/1 ... model.destroy();
// Custom response
{
"page": 1,
"limit": 10,
"total": 2,
"books": [
{"id": 1, "title": "Pride and Prejudice"},
{"id": 4, "title": "The Great Gatsby"}
]
}
// Custom parsing
var Books = Backbone.Collection.extend({
url: '/books',
parse: function(data) {
return data.books;
}
});
View Rendering
Routing with URLs
Backbone.Events
var object = {};
_.extend(object, Backbone.Events);
object.on("alert", function(msg) {
alert("Triggered " + msg);
});
object.trigger("alert", "an event");
-
"reset" (collection)
-
"sort" (collection)
-
"invalid" (model, error)
-
"request" (model_or_collection, xhr)
-
"sync" (model_or_collection, resp)
-
"error" (model_or_collection, resp)
-
"add" (model, collection)
-
"remove" (model, collection)
-
"update" (collection)
-
"change" (model)
-
"change:[attribute]" (model, value)
-
"destroy" (model, collection)
-
"route:[name]" (params)
-
"route" (route, params)
-
"route" (router, route, params)
-
"all"
Models
- Create models
- Attributes
- Validation
- Server sync
- Model events
- Model methods
Collections
- Creating Collections
- Managing Collections
- Collections sync
- Sorting Collections
- Collection events
Views
- Creating and Rendering
- Managing DOM Events
- Persisting Data
Router
- Creating Routers
- Adding Routers
- Navigating with links
AMD and CommonJS
- Browserify
- RequireJS
Plugins
Debugging
![](https://s3.amazonaws.com/media-p.slid.es/uploads/66414/images/1460724/Screen_Shot_2015-06-05_at_8.08.19_AM.png)
Frameworks
![](https://s3.amazonaws.com/media-p.slid.es/uploads/66414/images/1460769/logo.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/66414/images/1460774/chaplin-hat.png)
THORAX
Projects
![](https://s3.amazonaws.com/media-p.slid.es/uploads/66414/images/1460795/basecamp-a3c9e389acdeba3ac2bd084d0ce0462b.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/66414/images/1460793/Atlassian_Bitbucket_Logo.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/66414/images/1460796/wp-header-logo-2x.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/66414/images/1460799/New_Walmart_Logo.svg.png)
Lecture: Backbone.js overview
By Andrew Dacenko
Lecture: Backbone.js overview
- 1,169