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

MathJax filter does not work with with ajax

    XMLWordPrintable

    Details

    • Affected Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE

      Description

      The problem is that we only load MathJax on pages that need it, and only apply it to content that needs it.

      This is a problem when you are doing things with Ajax. If the inital page does not contain any mathematics, and then ajax tries to load some content that does contain mathematics, it is not rendered.

      Note that, to make this work, you already need code like

      if (typeof MathJax !== 'undefined') {
         MathJax.Hub.Queue(["Typeset", MathJax.Hub, this.validationdiv.getDOMNode()]);
      }
      

      in your ajax code, to get the maths rendered in content after you have added it to the DOM.

      Example steps to reproduce, using STACK, which is where I am hitting this:

      1. Install qtype_stack and all dependencies.
      2. Create a question with no TeX in the questiontext. (E.g. "What is one and one?")
      3. Preview the question, type something into the answer box.
      4. When the response validation runs, the maths in the new content is not rendered.

      This does not happend if there is an equation like

      \[1+1\]
      

      in the question text.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            timhunt Tim Hunt
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: