API Docs for: 1.0.0
Show:

Rebar.PersistenceModel Class

Extends Backbone.Model

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

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

(
  • model
  • options
)
private

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

(
  • method
  • model
  • options
)
private

Overridden to reroute the to a localStorage endpoint.

Parameters:

  • method String
  • model PersistenceModel
  • options Object