LS Developer
LS Developer

Reputation: 525

How to perform an action once Mathjax loaded completely?

I'm developing an online exam application.The questions contain just text or equations or both text and equations. The equations are displayed using Mathjax.There is a timer on the page. I want to start the timer only when the Mathjax equations are loaded completely.If the question doesn't contains any equation then the timer has to be started without waiting for Mathjax.How can this be done? The application is developed in PHP.

Upvotes: 1

Views: 742

Answers (1)

Davide Cervone
Davide Cervone

Reputation: 12260

You don't say if you are loading MathJax on every page, or just on the ones that include Math. If on all pages, then add

<script type="text/x-mathjax-config">
MathJax.Hub.Queue(function () {
  ... do whatever you need to start timer here ...
});
</script>

before the script that loads MathJax. This will cause the function to be performed after MathJax has finished its typesetting (and if there isn't any typesetting, it will still get done).

If you don't load MathJax on every page, then do this on the pages that do include MathJax, and just start the timer directly on those that don't.

Upvotes: 2

Related Questions