Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-47604

Need a general solution for handling required JS with Ajax

    XMLWordPrintable

    Details

    • Affected Branches:
      MOODLE_27_STABLE

      Description

      $PAGE->requires gives us a nice mechanism for initialising the JavaScript required when outputting a whole page.

      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?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                timhunt Tim Hunt
                Participants:
                Component watchers:
                Jake Dallimore, Jun Pataleta
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: