Replace dynamite code with tested version
This commit is contained in:
@@ -15,6 +15,7 @@ class @Problem
|
||||
@$('section.action input.reset').click @reset
|
||||
@$('section.action input.show').click @show
|
||||
@$('section.action input.save').click @save
|
||||
@$('input.math').keyup(@refreshMath).each(@refreshMath)
|
||||
|
||||
render: (content) ->
|
||||
if content
|
||||
@@ -62,6 +63,20 @@ class @Problem
|
||||
if response.success
|
||||
alert 'Saved'
|
||||
|
||||
refreshMath: (event, element) =>
|
||||
element = event.target unless element
|
||||
target = "display_#{element.id.replace(/^input_/, '')}"
|
||||
|
||||
if jax = MathJax.Hub.getAllJax(target)[0]
|
||||
MathJax.Hub.Queue ['Text', jax, $(element).val()]
|
||||
|
||||
try
|
||||
output = jax.root.toMathML ''
|
||||
$("##{element.id}_dynamath").val(output)
|
||||
catch exception
|
||||
throw exception unless exception.restart
|
||||
MathJax.Callback.After [@refreshMath, jax], exception.restart
|
||||
|
||||
refreshAnswers: =>
|
||||
@$('input.schematic').each (index, element) ->
|
||||
element.schematic.update_value()
|
||||
|
||||
Reference in New Issue
Block a user