-
Notifications
You must be signed in to change notification settings - Fork 0
alarie/BackboneStorage
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
HOW TO USE ---------- // Locally stored data var LocalObject = Backbone.Model.extend({, defaults : { ... }, localStorage : new Store("myLocalStore") }); // Remotely stored data var RemoteObject = Backbone.Model.extend({, defaults : { ... }, url : "my/remote/storage/" }); // It is also possible to have objects that are stored both, locally // and remote. In that case, you just have to specify where to save // or fetch data to/from. var HybridObject = Backbone.Model.extend({ defaults : { ... }, localStorage : new Store("myLocalStore"), url : "my/remote/storage/", fetch : function (opts) { opts.location = "local"; // default is remote Backbone.Model.prototype.fetch.apply(this, arguments); }, save : function (attrs, opts) { opts.location = "local"; // default is remote Backbone.Model.prototype.save.apply(this, arguments); } }); // It also works for collections.
About
Extension to Backbone.sync that automatically switches between RemoteStorage and LocalStorage based on the Backbone.Model's settings.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published