actually, since we do not know the code you are using i can just offer some alternative approach
document.body.innerHTML = "";
document.body.innerHTML = await response.text();
let uploadButton = document.getElementById('upload-button');
uploadButton.addEventListener('click', function() {
// your code here
});
it may be related to the script that should be bound to
or
document.body.innerHTML = "";
document.body.insertAdjacentHTML('afterbegin', await response.text());
or you can write a script
that adds HTML tags first and javascript tags later