Skip to content


Subversion checkout URL

You can clone with
Download ZIP


always use recommended localStorage getter/setters #23

wants to merge 1 commit into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 27, 2012
  1. @devinrhode2
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 9 deletions.
  1. +9 −9 README.textile
18 README.textile
@@ -134,21 +134,21 @@ It works the same as accessing an Object in JavaScript, but persists the
value across sessions.
-localStorage.title = "Welcome!"
-localStorage.title //=> "Welcome!"
+localStorage.setItem("title", "Welcome!")
+localStorage.getItem("title") //=> "Welcome!"
-delete localStorage.title
-localStorage.title //=> undefined
+localStorage.getItem("title") //=> null
Browsers can offer different amounts of storage using this API. The
iPhone, for instance, offers 5MB of storage, after which it asks the
user for permission to store an additional 10MB.
-You can reclaim storage from a key by <code>delete</code>ing it or
+You can reclaim storage from a key by using the <code>removeItem</code> it or
by overwriting its value. You can also enumerate over all keys in
the localStorage using the normal JavaScript <code>for/in</code>
In combination with the App Cache, you can use Local Storge to store
data on the device, making it possible to show stale data to your
@@ -170,7 +170,7 @@ jQuery(function($) {
// the HTML will be present regardless of online status
var updateArticles = function(object) {
template = $("#articles")
- localStorage.articles = JSON.stringify(object);
+ localStorage.setItem("articles", JSON.stringify(object));
@@ -199,7 +199,7 @@ jQuery(function($) {
// update the HTML with the stale articles. Even if
// the user never gets online, they will at least
// see the stale content
- if(localStorage.articles) updateArticles(JSON.parse(localStorage.articles));
+ if(localStorage.getItem("articles")) updateArticles(JSON.parse(localStorage.getItem("articles")));
// If the user was offline, and goes online, ask
// the server for updates
@@ -208,4 +208,4 @@ jQuery(function($) {
// If the user is online, ask for updates now
if(window.navigator.onLine) remoteUpdate();
Something went wrong with that request. Please try again.