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

Need a general solution for handling required JS with Ajax

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • 2.7.2
    • JavaScript
    • MOODLE_27_STABLE

      $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?

            Unassigned Unassigned
            timhunt Tim Hunt
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.