Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A localStorage adapter for Backbone.js
JavaScript
branch: master

This branch is 239 commits behind jeromegn:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tests
README.md
backbone.localStorage-min.js
backbone.localStorage.js

README.md

Backbone localStorage Adapter v1.0

Quite simply a localStorage adapter for Backbone. It's a drop-in replacement for Backbone.Sync() to handle saving to a localStorage database.

Usage

Include Backbone.localStorage after having included Backbone.js:

<script type="text/javascript" src="backbone.js"></script>
<script type="text/javascript" src="backbone.localStorage.js"></script>

Create your collections like so:

window.SomeCollection = Backbone.Collection.extend({

  localStorage: new Store("SomeCollection"), // Unique name within your app.

  // ... everything else is normal.

});

Feel free to use Backbone as you usually would, this is a drop-in replacement.

Credits

Thanks to Mark Woodall for the QUnit tests.

Something went wrong with that request. Please try again.