Last active
May 6, 2016 08:07
-
-
Save MeoBeoI/88c6c783088c3a96c1cf7dff4c819c90 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>CodeConCat - Firebase Example</title> | |
<script src="https://cdn.firebase.com/js/client/2.4.2/firebase.js"></script> | |
<script src="https://code.jquery.com/jquery-2.2.3.min.js" integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=" crossorigin="anonymous"></script> | |
</head> | |
<body> | |
<textarea id="text-area" cols="100" rows="10"></textarea> | |
<script type="text/javascript"> | |
// Connect to Firebase | |
var ref = new Firebase("https://100concats.firebaseio.com/text-area"); | |
// Change value when typing | |
$('#text-area').on('input', (e) => { | |
ref.set(e.target.value); | |
}) | |
// Update textarea when receving data | |
ref.on('value', (snapshot) => { | |
$('#text-area').val(snapshot.val()); | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment