Skip to content
Snippets Groups Projects
Commit 81d5c17a authored by Calen Pennington's avatar Calen Pennington
Browse files

Merge pull request #310 from MITx/arjun/javascript_loading

Adding the ability for javascript from problems to execute more intelligently
parents 6afe1709 c4c8bc2f
No related branches found
No related tags found
No related merge requests found
......@@ -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) =>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment