I have a Javascript loop function
firebase.auth().onAuthStateChanged((user) => {
if (user) {
database = firebase.database();
var BusinessesId = firebase.auth().currentUser.uid;
var ref = database.ref('/Jobs/');
ref.on('value', ApplicationData, errData);
}
})
function JobData(data) {
var container = document.getElementById('Jobs');
data.forEach(function(JobSnap) { // loop over all jobs
var key = JobSnap.key;
var Jobs = JobSnap.val();
var newCard = `
<div class="thumbnail" id="${key}">
<span class="folder"><span class="file"></span></span>
<div class="title" id="Jobs">${Jobs.JobTitle}</div>
</div>
`;
container.innerHTML += newCard;
console.log(key);
})
}
What I noticed is that whenever I leave the page on for some hours, the folders would have been multiplied. is like the everything is duplicated again. The longer I left it opened the more the retrieved data duplicates itself. for example, if I left the webpage opened and walked away for about an hour or so by the time i come back their will be two duplicates of each folder showed below. What is causing this and how can I stop it?
