diff --git a/app/assets/javascripts/live-coder.js b/app/assets/javascripts/live-coder.js.erb similarity index 93% rename from app/assets/javascripts/live-coder.js rename to app/assets/javascripts/live-coder.js.erb index 099766b..360b996 100644 --- a/app/assets/javascripts/live-coder.js +++ b/app/assets/javascripts/live-coder.js.erb @@ -14,19 +14,24 @@ function updateResults(elem) { codeFrame.setAttribute("height", "100%"); resultsContainer.appendChild(codeFrame); + var jqueryNode = document.createElement("script"); + jqueryNode.setAttribute("type", "text/javascript"); + jqueryNode.setAttribute("src", "<%= "//#{ENV['full_app_url']}#{javascript_path "jquery"}" %>"); + iHead.appendChild(jqueryNode); + var codeStyle = document.createElement("style"); codeStyle.setAttribute("type", "text/css"); var rulesNode = document.createTextNode(codeCss); codeStyle.appendChild(rulesNode); iHead.appendChild(codeStyle); - iDoc.appendChild(iHead); + iDoc.appendChild(iHead); iBody.innerHTML = codeHtml; iDoc.appendChild(iBody); var codeScript = document.createElement("script"); codeScript.setAttribute("type", "text/javascript"); - var scriptNode = document.createTextNode(codeJs); + var scriptNode = document.createTextNode("setTimeout(function(){ " + codeJs + "}, 800);"); codeScript.appendChild(scriptNode); iDoc.appendChild(codeScript);