Rebar.PersistenceModel Class
The PeristenceModel
extends the basic Backbone.Model
and overwrites its sync method to take advantage of local storage and persist data
across multiple pages within the same domain. The url property is used to grab data
from a specific object of the localStorage object. Use the fetch
method to pull
whatever data already exists in localStorage and use the save
method to store for
later use.
Constructor
Rebar.PersistenceModel
()
Example:
var model = new Backbone.Rebar.PersistenceModel({
url:"custom"
});
model.fetch();
model.set("foo","bar");
model.save();
Item Index
Methods
Methods
getStoargeId
()
String
private
Determains and returns a storage id based on the passed id in initialization
Returns:
String:
storage id for this persistence model
pullLocalStore
(
private
-
model
-
options
Helper method pulls data based on urlRoot from local storage
Parameters:
-
model
PersistenceModel -
options
Object
set
(
-
key
-
val
-
options
Overriden to make sure that we have a urlRoot on our persistence model
Parameters:
-
key
Object -
val
Object -
options
Object
sync
(
private
-
method
-
model
-
options
Overridden to reroute the to a localStorage endpoint.
Parameters:
-
method
String -
model
PersistenceModel -
options
Object