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

require_js causes problems when called within header

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 1.9
    • Component/s: JavaScript
    • Labels:
      None
    • Database:
      Any
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      require_js currently works in two situations:

      1) If you call it before print_header
      2) If you call it after print_header

      It does not cope with the third situation, which is if you have some code that runs as a consequence of the header code itself. (E.g. your header has some fancy JS in it.) When this happens, it tends to print the script at the beginning of the html file, which makes a mess of the page in IE6 because it breaks doctype detection.

      My proposal (and patch) is as follows:

      1) Rewrite require_js to support three defined states: before header, after header, and inside header.
      2) Add a line of code to weblib print_header so that it dumps the 'inside header' stuff out after the end of the header.
      3) Add debugging to check that the two 'special-case' variants of require_js (used when printing the header etc) are not called more than once or in the wrong order.
      4) Refactor require_js a bit and improve comments.

        Attachments

          Activity

            People

            • Assignee:
              quen Sam Marshall
              Reporter:
              quen Sam Marshall
              Tester:
              Nobody
              Participants:
              Component watchers:
              Jake Dallimore, Jun Pataleta, Ryan Wyllie
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                3/Mar/08