Skip to content

Commit

Permalink
convert boolean values in localStorage from string
Browse files Browse the repository at this point in the history
  • Loading branch information
mboinet committed May 20, 2013
1 parent cb66566 commit dbf219e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/scripts/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ define(['api','backbone','utils'],
for (var i = 0; i < window.localStorage.length; i++){
var key = window.localStorage.key(i);
var val = window.localStorage.getItem(key);
if (val != null){
if (key === "articlesOldestFirst"){
// Convert value back from string to boolean.
val = val == "true";
}
model.set(key, val);

// convert booleans values from string
if (val == "true" || val == "false"){
val = (val == "true");
}

model.set(key, val);
}
} else if (method == "update"){
/* write to localStorage every changed attributes */
Expand Down

0 comments on commit dbf219e

Please sign in to comment.