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.
This commit is contained in:
@@ -31,8 +31,20 @@ class @Problem
|
|||||||
else
|
else
|
||||||
$.postWithPrefix "#{@url}/problem_get", (response) =>
|
$.postWithPrefix "#{@url}/problem_get", (response) =>
|
||||||
@el.html(response.html)
|
@el.html(response.html)
|
||||||
|
@executeProblemScripts()
|
||||||
@bind()
|
@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: =>
|
check: =>
|
||||||
Logger.log 'problem_check', @answers
|
Logger.log 'problem_check', @answers
|
||||||
$.postWithPrefix "#{@url}/problem_check", @answers, (response) =>
|
$.postWithPrefix "#{@url}/problem_check", @answers, (response) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user