Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!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
You can’t perform that action at this time.