Store models in localStorage
Now that you know how to store and retrieve data from localStorage, it's time to store your models. In the following figure, you can see how to make data storage in local instead of a remote server.
By default, when you call the save() method on a model Backbone, it transforms the action into an HTTP request for a RESTFul server. To store the data in local, you need to change the default behavior in order to use localStorage instead of making HTTP requests; you will learn how to do this in the next section.
To make the storage layer maintainable, you will need to create a Backbone driver for localStorage first. The responsibility of the driver is to store and retrieve data from localStorage so that the connection between ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access