Created
July 10, 2015 16:04
-
-
Save andrebaltieri/40e6a19fffef7ec700b2 to your computer and use it in GitHub Desktop.
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
<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