Load JS on lightbox

Hello, I am facing up a strange issue when trying to load a JS on a lightbox view.

On lightbox is loaded a view using the "elgg_view('my_plugin/my_plugin_view', $vars)".

On this view there is the following:

elgg_require_js('my_plugin/my_plugin_js');

When click on the button to open the lightbox, the my_plugin_js.js is loaded on the popup window without issues. But if close the lightbox and open it again the my_plugin_js.js in not loaded.

If refresh the page and click again on the same button, it works fine but not if close and re-open the lightbox.

The Elgg version is 3.3.17.

Any ideas what could be wrong or missing?