Refresh popup content on open/close

Is it possible to refresh the content inside a popup when the popup is opened or closed? For example, my popup contains a .data-table with a search bar to filter the table. If I filter the table and then open the popup again at a later stage to search for something else, the search bar still contains the text from before.

Therefore every time I open the popup I would like the content to be refreshed.

$$('.popup-search').on('popup:opened', function (e, popup) {
  //refresh code here?


$$('.popup-search').on('popup:closed', function (e, popup) {

searchbar.clear(); Clear search query and update results

I couldn’t get that working. I was able to get this working:

document.getElementById("search").value = "";

But how can I translate that to DOM7?