JQuery Load() and Mathjax

295 views
Skip to first unread message

Adi

unread,
May 24, 2011, 5:01:51 PM5/24/11
to MathJax Users
Hi,

I have a section on my project where I load an aspx page using jquery
like in
$('#divexample).load("/MathjaxTesting.aspx");

The page I want to load has Mathml included but it cannot be displayed
unless it is loaded as a result of a postback. Is there a way I can
force rendering of the mathml without a postback?

Thank you.

Adi

unread,
May 27, 2011, 4:09:59 PM5/27/11
to MathJax Users
Found the comments, use

var math = document.getElementById("id");
MathJax.Hub.Queue(["Typeset", MathJax.Hub, math]);

Davide P. Cervone

unread,
May 30, 2011, 8:39:43 AM5/30/11
to mathja...@googlegroups.com
You need to be careful about the synchronization of the MathJax
actions and the jQuery load action. You need to be sure that the
MathJax typeset call does not occur until after the jQuery load is
complete. It is not clear where you have put the code
MathJax.Hub.Queue command that you listed, but it should be part of a
callback for the jQuery load command, as in:

$('#divexample).load("/MathjaxTesting.aspx", function ()
{MathJax.Hub.Queue(["Typeset",MathJax.Hub,"divexample"])});

The INCORRECT way would be

$('#divexample).load("/MathjaxTesting.aspx");
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"divexample"]);

since the contents of the divexample element might not have been
loaded yet when the MathJax.Hub.Typeset command is performed. It
might work, depending on the timing of the load, and the contents of
you cache, but there is no guarantee, and it may well not work for
some or all of your readers.

Davide

Reply all
Reply to author
Forward
Message has been deleted
0 new messages