Skip to content

Instantly share code, notes, and snippets.

@selynna
Created July 2, 2015 18:53
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 selynna/0ee6d2770364fb47f585 to your computer and use it in GitHub Desktop.
Save selynna/0ee6d2770364fb47f585 to your computer and use it in GitHub Desktop.
Firebase issues
//Delete an existing task
var deleteTask = function() {
debugger
console.log("Delete task...");
var listItem = this.parentNode;
var ul = listItem.parentNode;
//delete from firebase
fb.once('value', function(snapshot) {
var children = snapshot.val();
for (var child_id in children) {
var child = fb.child(child_id);
console.log("The key is: " + child_id);
console.log("The listItem is: " + listItem);
console.log("The item is: " + child_id.item);
// => the item is: undefined
console.log(child);
// => undefined
console.log(child_id.val());
// => undefined
console.log(child.val());
// => undefined
console.log(child.item);
// => undefined
child.remove();
//if listItem value equals the key then remove that key
// if (listItem.getElementsByTagName("label")[0].innerHTML == child_id.item) {
// child.remove();
// break;
// }
}
//Remove the parent list item from the ul
ul.removeChild(listItem);
//.key()
//console.log(child.key());
// child.remove();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment