But, in the case when we are re-loading part of a page through an Ajax request, there is no equivalent mechanism.
In the AJAX_SCRIPT $PAGE->requires will collect all the necssary JS, but then it is thrown away.
I guess we need a way to put that information into the JSON response, and then have a helper in M.util (or somewhere) to receive that response, and run the JS.
I found this while working on
MDL-43089. Look at load_done in mod/quiz/yui/src/quizquestionbank/js/quizquestionbank.js. That is having to manually call all the necessary init methods, but that is very fragile. What if one of the other parts of Moodle changes its JS?