Created
January 27, 2013 12:24
-
-
Save glynrob/4648138 to your computer and use it in GitHub Desktop.
Save data with websql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function saveLocally(dataToSave){ | |
db.transaction(function (tx) { // this is nasty but truncate is not available on sqllite | |
tx.executeSql('DROP TABLE data '); | |
tx.executeSql('CREATE TABLE IF NOT EXISTS data (id unique, text)'); | |
}); | |
$.each(dataToSave, function(key, val) { // loop through each item in savedData | |
if (val){ | |
db.transaction(function (tx) { | |
tx.executeSql('INSERT INTO data (id, text) VALUES (?, ?)', [val['label'], val['value']]); | |
}); | |
} | |
}); | |
showListItems(); // refresh the list display | |
showLocalData(); // update localdata display | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment