Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/domchristie/backbone-store-collection
Extends a collection's get method to fetch models from the server if not found locally
https://github.com/domchristie/backbone-store-collection
Last synced: 12 days ago
JSON representation
Extends a collection's get method to fetch models from the server if not found locally
- Host: GitHub
- URL: https://github.com/domchristie/backbone-store-collection
- Owner: domchristie
- Created: 2012-08-31T16:13:35.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2012-09-01T16:14:30.000Z (about 12 years ago)
- Last Synced: 2023-04-09T21:37:15.165Z (over 1 year ago)
- Language: JavaScript
- Size: 97.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Backbone Store Collection
=========================Extends a collection's `get` method to fetch models from the server if not found locally.
Write ups: [Using Backbone.js Class Properties as Data Stores](http://domchristie.co.uk/posts/31) and [Part 2](http://domchristie.co.uk/posts/32)
Usage
-----Posts = Backbone.StoreCollection.extend({
url: '/posts'
});
var posts = new Posts(),
post = new Backbone.Model({ id: 1 });
posts.add(post);
// Retrieving model from collection
posts.get(1, function() {
success: function(model, response) {
// do something with model
}
});
// Fetching model from server
posts.get(32, function() {
success: function(model, response) {
// do something with model
},
error: function(model, response) {
// say sorry
}
});Todo
----
Add tests.Licence
-------
Backbone Store Collection is copyright © 2012 [Dom Christie](http://domchristie.co.uk) and released under the MIT license.