Skip to content

Instantly share code, notes, and snippets.

@cfjedimaster
Created May 14, 2012 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfjedimaster/2696417 to your computer and use it in GitHub Desktop.
Save cfjedimaster/2696417 to your computer and use it in GitHub Desktop.
function displayNotes() {
var transaction = db.transaction(["note"], IDBTransaction.READ);
var content="<ul>";
transaction.oncomplete = function(event) {
console.log("All done!");
$("#noteList").html(content);
};
transaction.onerror = function(event) {
// Don't forget to handle errors!
console.dir(event);
};
var objectStore = transaction.objectStore("note");
objectStore.openCursor().onsuccess = function(event) {
var cursor = event.target.result;
if (cursor) {
content += "<li data-key=\""+cursor.key+"\"><span class=\"label\">"+cursor.value.title+"</span>";
content += " <a class=\"delete\">[Delete]</a>";
content +="</li>";
cursor.continue();
}
else {
content += "</ul>";
console.log("Done with cursor");
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment