Commit 6a16af2a by kimth

MathJax initial render needs to be properly queued

parent 3173334d
...@@ -12,6 +12,7 @@ class @Problem ...@@ -12,6 +12,7 @@ class @Problem
bind: => bind: =>
MathJax.Hub.Queue ["Typeset", MathJax.Hub] MathJax.Hub.Queue ["Typeset", MathJax.Hub]
window.update_schematics() window.update_schematics()
problem_prefix = @element_id.replace(/problem_/,'') problem_prefix = @element_id.replace(/problem_/,'')
...@@ -23,7 +24,11 @@ class @Problem ...@@ -23,7 +24,11 @@ class @Problem
@$('section.action input.reset').click @reset @$('section.action input.reset').click @reset
@$('section.action input.show').click @show @$('section.action input.show').click @show
@$('section.action input.save').click @save @$('section.action input.save').click @save
@$('input.math').keyup(@refreshMath).each(@refreshMath)
# Dynamath
@$('input.math').keyup(@refreshMath)
@$('input.math').each (index, element) =>
MathJax.Hub.Queue [@refreshMath, null, element]
updateProgress: (response) => updateProgress: (response) =>
if response.progress_changed if response.progress_changed
...@@ -297,7 +302,6 @@ class @Problem ...@@ -297,7 +302,6 @@ class @Problem
refreshMath: (event, element) => refreshMath: (event, element) =>
element = event.target unless element element = event.target unless element
elid = element.id.replace(/^input_/,'') elid = element.id.replace(/^input_/,'')
target = "display_" + elid target = "display_" + elid
# MathJax preprocessor is loaded by 'setupInputTypes' # MathJax preprocessor is loaded by 'setupInputTypes'
...@@ -308,9 +312,10 @@ class @Problem ...@@ -308,9 +312,10 @@ class @Problem
eqn = $(element).val() eqn = $(element).val()
if mathjax_preprocessor if mathjax_preprocessor
eqn = mathjax_preprocessor(eqn) eqn = mathjax_preprocessor(eqn)
MathJax.Hub.Queue ['Text', jax, eqn], MathJax.Hub.Queue(['Text', jax, eqn], [@updateMathML, jax, element])
[@updateMathML, jax, element]
return # Explicit return for CoffeeScript
updateMathML: (jax, element) => updateMathML: (jax, element) =>
try try
$("##{element.id}_dynamath").val(jax.root.toMathML '') $("##{element.id}_dynamath").val(jax.root.toMathML '')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment