I am using Backbone.LocalStorage: http://jsfiddle.net/jiewmeng/grhz9/3/
$(function() {
console.log(Backbone.LocalStorage); // undefined!!
var Todo = Backbone.Model.extend({});
var Todos = Backbone.Collection.extend({
model: Todo,
localStorage: new Backbone.LocalStorage("todos")
});
});
The 1st console.log() gives undefined. Then there an error at the localStorage: ... line
Uncaught TypeError: undefined is not a function
Expected since Backbone.LocalStorage is undefined but why?
The
backbone.localStorage-min.jsyou're loading:looks like it is out of date and it doesn't define
Backbone.LocalStorageat all. The version ofbackbone.localStorage-min.jsthat you are using defineswindow.Storerather thanBackbone.LocalStorage. If you switch to that (http://jsfiddle.net/ambiguous/grhz9/5/):then you can get past building your
Todoscollection. I don't know how well things will work when you actually try to use it though. "Sun Aug 14 2011 09:53:55 -0400" is pretty much forever-ago in internet time so that version is rather antique.If you switch to the latest version from Github:
you'll see that there are a few differences in the JavaScript and everything will start working when you use
new Backbone.LocalStorage('todos'):