The problem I'm currently wrestling with is this. Haven't realised what the issue was but i have the following code
j.prototype.deleteFile = function()
{
$('.deleteFile').on('click', function()
{
if(confirm('Are you sure you want to delete this file?'))
{
//delete the file
}
})
}
The purpose of this is to delete files on button click and confirmation of deletion. Since file icons are added upon uploading (appended afterwards) and this is called upon page load (since upon page load there might already be files for deletion) i need to refetch the HTML elements to have an up to date list as i understand. This creates multiple instances of the function as it is called multiple times (for each upload) and thus when trying to delete a file:
- After first upload asks for confirmation once
- After second upload, second upload asks for confirmation once, first one twice.
The pattern is to add additional one for the ones existing before. I assume it is because deleteFile has multiple instances and each of them triggers upon click.
I have been looking for a way to clear the old instances or maybe add/include new elements to that old instance but to now avail.
Is there a method for achieving my goal that I'm overlooking maybe?