WebStorage
Var Model = Backbone.Model.extend({
Prefix: “articles”,
save: function() {
localStorage.setItem(“articles-” + this.id,
this.toJSON().toString())
},
fetch: function() {
Var data = localStorage.getItem(“articles-” + this.id);
If (_.isString(data)) {
Try {
Data = JSON.parse(data);
} catch (e) {
Data = {}
} finally {
This.set(data)
}
}
}
})