Skip to content

Instantly share code, notes, and snippets.

@andrebaltieri
Created July 10, 2015 16:04
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 andrebaltieri/40e6a19fffef7ec700b2 to your computer and use it in GitHub Desktop.
Save andrebaltieri/40e6a19fffef7ec700b2 to your computer and use it in GitHub Desktop.
<script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>
<script type="text/javascript">
var db = new Firebase('https://chat-balta-demo.firebaseio.com/chat');
$('#send-button').click(function () {
var message = $('#text-message').val();
db.push({ message: message });
$('#text-message').val("");
});
db.on('child_added', function(snapshot) {
var data = snapshot.val();
$('#messages').append($('<li>').text(data.message));
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment