Firebase Test 2 (deletion)
HTML
<script src="https://cdn.firebase.com/v0/firebase.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css">
<div id='thingList'></div>
<i class="icon-plus"></i><input type='text' id='thingTitle' placeholder='Title'>
JavaScript
var ref = new Firebase('https://xxx.firebaseio.com/things');
$('#thingTitle').keypress(function (e) {
if (e.keyCode == 13) {
var thingTitle = $('#thingTitle').val();
ref.push({
thingTitle: thingTitle
});
$('#thingTitle').val('');
}
});
ref.limit(10).on('child_added', function (snapshot) {
var thing = snapshot.val();
var thisItem = '';
thisItem += '<span class=remover width=10><i class="icon-remove"></i></span>';
thisItem += thing.thingTitle;
$('#thingList').append('<div id=id' + snapshot.name() + '>' + thisItem + '</div>');
$('#thingList')[0].scrollTop = $('#thingList')[0].scrollHeight;
});
ref.limit(20).on("child_removed", function (snapshot) {
$('#id' + snapshot.name()).remove()
});
$(document).on('click', '.remover', function () {
var id = $(this).parent().attr("id").substring(2)
ref.child(id).once('value', function (snapshot) {
snapshot.ref().remove();
});
});
// http://screencast.com/t/0ICuBQqjU3XD