How to refresh panel scripts?

I have a panel, which contains a list of items. I have a JS file attached to the panel with addscript and that javascript interacts great with the html list, but the moment I try to update the html using sethtml it breaks that JS from running. I am guessing that the JS code is wiped out, or broken due to DOM objects no longer working?

I tried re-adding the addscript after re-doing the sethtml but that does not seem to work.

What is a good workaround for this?

Thank you