Skip to content

Commit

Permalink
delegate to normal Backbone.sync if there is no storage found
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpiano committed Aug 17, 2011
1 parent 10e1bbe commit a382740
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backbone.localStorage.js
Expand Up @@ -74,9 +74,11 @@

});

var normalSync = Backbone.sync;

// Override `Backbone.sync` to use delegate to the model or collection's
// *localStorage* property, which should be an instance of `Store`.
// If there is no storage found, use the normal Backbone.sync
Backbone.sync = function(method, model, options, error) {

// Backwards compatibility with Backbone <= 0.3.3
Expand All @@ -94,7 +96,7 @@
store = model.collection.localStorage || model.collection.sessionStorage;
}
if (!store) {
return error("No storage found");
return normalSync.apply(this, _.toArray(arguments));
}

switch (method) {
Expand Down

0 comments on commit a382740

Please sign in to comment.