jeromegn/Backbone.localStorage

localStorage attrib a function?

Closed this issue · 2 comments

Hi there,

just an idea: would it be possible to define the localstorage property on collections and models as a function?

i want to dynamically set the storage key, like that:

localStorage: function() {
    return new Backbone.LocalStorage(this.storageKey);
}

Or do you have another way to achieve this?

Thanks for your great little lib!

We could use _.result(this, 'localStorage') to get the value. Feel free to create a PR :)

OK. thanks. I solved it by initializing the LocalStorage in the constructor of the collection.