From 7e13ed59a868e917dcccce5f550b3c4ad2619af9 Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Wed, 3 Aug 2016 15:22:54 -0500 Subject: [PATCH] added jquery to live-coder iframes --- .../javascripts/{live-coder.js => live-coder.js.erb} | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) rename app/assets/javascripts/{live-coder.js => live-coder.js.erb} (93%) 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);