summaryrefslogtreecommitdiff
path: root/jslib/urweb.js
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-01-11 10:41:38 -0500
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-01-11 10:41:38 -0500
commitd71a90ca23170fd7fef9ad0f9ccf6afc01d3f372 (patch)
tree78e67b40776c15813d38f98e1ca793a30a4a4792 /jslib/urweb.js
parent23a1c7d1de76762465f90635a5e31f58b46fe611 (diff)
Do proper insertion of dynamic content within nested DOM containers
Diffstat (limited to 'jslib/urweb.js')
-rw-r--r--jslib/urweb.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/jslib/urweb.js b/jslib/urweb.js
index 0f9c06cf..8e39f9f3 100644
--- a/jslib/urweb.js
+++ b/jslib/urweb.js
@@ -34,17 +34,26 @@ function sb(x,y) {
return s;
}
+function myParent() {
+ var pos = document;
+
+ while (pos.lastChild && pos.lastChild.nodeType == 1)
+ pos = pos.lastChild;
+
+ return pos.parentNode;
+}
+
function dyn(s) {
var x = document.createElement("span");
x.innerHTML = s.v;
- document.body.appendChild(x);
+ myParent().appendChild(x);
s.h = cons(function() { x.innerHTML = s.v }, s.h);
}
function inp(t, s) {
var x = document.createElement(t);
x.value = s.v;
- document.body.appendChild(x);
+ myParent().appendChild(x);
s.h = cons(function() { x.value = s.v }, s.h);
x.onkeyup = function() { sv(s, x.value) };
}