From e64a27b444ef683356d91f4391f8f8f190053eeb Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Fri, 3 Aug 2012 08:38:47 -0400 Subject: Undo change to script evaluation, originally made to support + 'giveFocus'; alternate approach to making 'giveFocus' work in dynamic code generatione --- lib/js/urweb.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lib/js') diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 4ef77599..b8ebc1c6 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -815,6 +815,7 @@ function dyn(pnode, s) { var dummy = document.createElement("body"); dummy.innerHTML = "" + html + "
"; + runScripts(dummy); var table = x.parentNode; if (table) { @@ -842,12 +843,12 @@ function dyn(pnode, s) { for (var node = tbody.firstChild; node; node = next) { next = node.nextSibling; table.insertBefore(node, x); - runScripts(node); } } } else if (pnode == "tr") { var dummy = document.createElement("body"); dummy.innerHTML = "" + html + "
"; + runScripts(dummy); var table = x.parentNode; if (table) { @@ -865,15 +866,14 @@ function dyn(pnode, s) { for (var node = tr.firstChild; node; node = next) { next = node.nextSibling; table.insertBefore(node, x); - runScripts(node); } } } else { firstChild = document.createElement("span"); firstChild.innerHTML = html; + runScripts(firstChild); if (x.parentNode) x.parentNode.insertBefore(firstChild, x); - runScripts(firstChild); } }; @@ -1863,12 +1863,14 @@ function fresh() { } function giveFocus(id) { - var node = document.getElementById(id); + window.setTimeout(function() { + var node = document.getElementById(id); - if (node) - node.focus(); - else - er("Tried to give focus to ID not used in document: " + id); + if (node) + node.focus(); + else + er("Tried to give focus to ID not used in document: " + id); + }, 0); } -- cgit v1.2.3