Backbone.js Todos example app comes with a nifty localStorage adapter which allows Backbone to transparently save data locally. That's all kinds of awesome, however, the way it's written, it overrides Backbone.sync
globally, so you're left with localStorage as your only option.
This small change I made to it ensures that only when you extend
a model or a collection with localStorage
as a parameter, that model/collection in particular will be local while everything else works normally.
Note that this line here
if ('localStorage' in window)
ensures that it'll only work in browsers that support the localStorage API. _You'd be better off testing that with yepnope.js and loading this feature conditionally).