Mercurial > urweb
diff lib/js/urweb.js @ 1040:ca5136105c45
Get dynamic <select> working in IE
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 22 Nov 2009 16:40:09 -0500 |
parents | 8932f855fa85 |
children | 0d767c8d2923 |
line wrap: on
line diff
--- a/lib/js/urweb.js Sun Nov 22 15:30:15 2009 -0500 +++ b/lib/js/urweb.js Sun Nov 22 16:40:09 2009 -0500 @@ -445,8 +445,7 @@ 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 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 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 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) };