summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/js/urweb.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 15ff7bf2..4ee7be4b 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -445,8 +445,7 @@ function dyn(pnode, s) {
populate(x);
}
-function input(t, s, recreate, type) {
- var x = document.createElement(t);
+function input(x, s, recreate, type) {
if (type) x.type = type;
x.dead = false;
x.signal = ss(s);
@@ -459,7 +458,8 @@ function input(t, s, recreate, type) {
}
function inp(s) {
- var x = input("input", s, function(x) { return function(v) { if (x.value != v) x.value = v; }; });
+ var x = input(document.createElement("input"), s,
+ function(x) { return function(v) { if (x.value != v) x.value = v; }; });
x.value = s.data;
x.onkeyup = function() { sv(s, x.value) };
@@ -467,8 +467,9 @@ function inp(s) {
}
function sel(s, content) {
- var x = input("select", s, function(x) { return function(v) { if (x.value != v) x.value = v; }; });
- x.innerHTML = content;
+ var dummy = document.createElement("span");
+ dummy.innerHTML = "<select>" + content + "</select>";
+ var x = input(dummy.firstChild, s, function(x) { return function(v) { if (x.value != v) x.value = v; }; });
x.value = s.data;
if (x.value != s.data)
sv(s, x.value);
@@ -478,7 +479,8 @@ function sel(s, content) {
}
function chk(s) {
- var x = input("input", s, function(x) { return function(v) { if (x.checked != v) x.checked = v; }; }, "checkbox");
+ var x = input(document.createElement("input"), s,
+ function(x) { return function(v) { if (x.checked != v) x.checked = v; }; }, "checkbox");
x.checked = s.data;
x.onchange = function() { sv(s, x.checked) };