IE Error - Unable to get value of the property 'getItem': object is null or undefined #55

Closed
LeeGDavis opened this Issue Dec 16, 2012 · 4 comments

3 participants

@LeeGDavis

I receive the following error using localStorage in a Backbone Collection when using IE9. Works great in firefox, opera, but IE9 not so much.

"SCRIPT5007: Unable to get value of the property 'getItem': object is null or undefined
backbone.localStorage.js, line 29 character 3"

offending line --> var store = this.localStorage().getItem(this.name);

I have dom storage turned on in IE, I don't know what else I need. I'm new to backbone and the localStorage Adaptor, so hopefully I'm just doing something stupid.

I am using requirejs, but have created the necessary shim to use localStorage and like I said IE is the only issue other browser vendors works fine.

var TodosCollection = Backbone.Collection.extend({
model: Todo,
localStorage: new Backbone.LocalStorage('todos-backbone')
});

@jeromegn
Owner

How are you accessing the page? Locally? (ie: "file://")

If you type window.localStorage in the browser's console, what do you get?

@LeeGDavis

Yes, locally... Just fired it up on my server and worked just fine. Is there a trick to getting this working locally off the filesystem and what is the issue?

window.localStorage:

  • local (file://): undefined
  • Server (http://): object storage

Cheers
Lee

@gsmaverick

@LeeGDavis there isn't a trick for local filesystem it just doesn't work. For localstorage to work you must be loading the page off of a server.

@LeeGDavis

No worries, thanks guys. Appreciate the help with this one!

@LeeGDavis LeeGDavis closed this Dec 16, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment