Old Guides - You are viewing the guides for
Ember
v1.10.0.
Finally we'll replace our fixture data with real persistence so todos will remain between application loads by replacing the fixture adapter with a localstorage
-aware adapter instead.
Change js/application.js
to:
window.Todos = Ember.Application.create();
Todos.ApplicationAdapter = DS.LSAdapter.extend({
namespace: 'todos-emberjs'
});
The local storage adapter, written by Ryan Florence, can be downloaded from its source. Add it to your project as js/libs/localstorage_adapter.js
. You may place this file anywhere you like (even just putting all code into the same file), but this guide will assume you have created the file and named it as indicated.
In index.html
include js/libs/localstorage_adapter.js
as a dependency:
<!--- ... additional lines truncated for brevity ... -->
<script src="js/libs/ember-data.js"></script>
<script src="js/libs/localstorage_adapter.js"></script>
<script src="js/application.js"></script>
<!--- ... additional lines truncated for brevity ... -->
Reload your application. Todos you manage will now persist after the application has been closed.