Commit c4c8bc2f by Arjun Singh

Adding the ability for javascript from problems to execute more intelligently;…

Adding the ability for javascript from problems to execute more intelligently; for example, errors from javascript included in the returned html will show up in the console when using this mechanism.
parent 6afe1709
......@@ -31,8 +31,20 @@ class @Problem
else
$.postWithPrefix "#{@url}/problem_get", (response) =>
@el.html(response.html)
@executeProblemScripts()
@bind()
executeProblemScripts: ->
@el.find(".script_placeholder").each (index, placeholder) ->
s = $("<script>")
s.attr("type", "text/javascript")
s.attr("src", $(placeholder).attr("data-src"))
# Need to use the DOM elements directly or the scripts won't execute
# properly.
$('head')[0].appendChild(s[0])
$(placeholder).remove()
check: =>
Logger.log 'problem_check', @answers
$.postWithPrefix "#{@url}/problem_check", @answers, (response) =>
......
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