1 _kiwi
.model
.DataStore
= Backbone
.Model
.extend({
2 initialize: function () {
7 namespace: function (new_namespace
) {
8 if (new_namespace
) this._namespace
= new_namespace
;
9 return this._namespace
;
12 // Overload the original save() method
14 localStorage
.setItem(this._namespace
, JSON
.stringify(this.attributes
));
17 // Overload the original load() method
19 if (!localStorage
) return;
24 data
= JSON
.parse(localStorage
.getItem(this._namespace
)) || {};
29 this.attributes
= data
;
34 // Generates a new instance of DataStore with a set namespace
35 instance: function (namespace, attributes
) {
36 var datastore
= new _kiwi
.model
.DataStore(attributes
);
37 datastore
.namespace(namespace);