firebase.database().ref('zones').on('value', (snapper) => {
//For each zone, populate HTML
snapper.forEach((snap) => {
var html = '<div id="child">Blahblah</div>';
//Add the Injected HTML to the parent div called 'new'
$("#parent").append(html);
}
});
<!-- this is the parent div where I inject my HTML from JS -->
<div id="parent">
</div>
I have a div that I am dynamically populating through a query from Firebase. My firebase query retrieves data that I inject into HTML using $("#parent").append(html)
.
Now once this parent div is all populated from the firebase call and html injection, I then want to run a function on that parent div - which basically sorts each child div numerically.
I can't seem to figure out how to wait for the parent div to finish populating completely before running the function I want to. I know that due to asynchronous operations, my function is running before the parent div is even getting populated and thus my issue...