I get an error in my console, which says "Firebase is not defined".
1. Seems like this "base" code haven't loaded before the other one.
EDIT cannot put the script in the header so need to do it this way
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://cdn.firebase.com/v0/firebase.js";
document.head.appendChild(script);
2. So I need to delay these somehow. How would I achieve that?
var myDataRef = new Firebase('https://eloquatest.firebaseio.com/');
myDataRef.on('child_added', function(snapshot) {
var post = snapshot.val();
});
function submitPost(e) {
var myDataRef = new Firebase('https://eloquatest.firebaseio.com/');
var name = $('#field0').val();
myDataRef.push({name: name});
$('#field0').val('');
}
3. I tried to put it within $( document ).ready(function()
but didn't work.
Link: https://learn.jquery.com/using-jquery-core/document-ready/