Created
July 2, 2015 18:53
-
-
Save selynna/0ee6d2770364fb47f585 to your computer and use it in GitHub Desktop.
Firebase issues
This file contains 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
//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