Skip to content

Instantly share code, notes, and snippets.

@MeoBeoI
Last active May 6, 2016 08:07
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 MeoBeoI/88c6c783088c3a96c1cf7dff4c819c90 to your computer and use it in GitHub Desktop.
Save MeoBeoI/88c6c783088c3a96c1cf7dff4c819c90 to your computer and use it in GitHub Desktop.
<!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