Mercurial > urweb
diff lib/js/urweb.js @ 1491:b2ca3e1e5b40
Fixes for detecting pastes and autocompletes for dynamic textboxes
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Fri, 15 Jul 2011 10:02:54 -0400 |
parents | 290de2dcecf6 |
children | 3c0803c1acd7 |
line wrap: on
line diff
--- a/lib/js/urweb.js Fri Jul 08 13:33:26 2011 -0400 +++ b/lib/js/urweb.js Fri Jul 15 10:02:54 2011 -0400 @@ -277,11 +277,13 @@ return {data : v, dyns : null}; } function sv(s, v) { - s.data = v; + if (s.data != v) { + s.data = v; - for (var ls = s.dyns; ls; ls = ls.next) - if (!ls.dead) - populate(ls.data); + for (var ls = s.dyns; ls; ls = ls.next) + if (!ls.dead) + populate(ls.data); + } } function sg(s) { return s.data; @@ -491,7 +493,7 @@ var x = input(document.createElement("input"), s, function(x) { return function(v) { if (x.value != v) x.value = v; }; }, null, name); x.value = s.data; - x.onkeyup = function() { sv(s, x.value) }; + x.onkeyup = x.oninput = x.onchange = x.onpropertychange = function() { sv(s, x.value) }; return x; } @@ -545,7 +547,7 @@ var x = input(document.createElement("textarea"), s, function(x) { return function(v) { if (x.innerHTML != v) x.innerHTML = v; }; }); x.innerHTML = s.data; - x.onkeyup = function() { sv(s, x.value) }; + x.onkeyup = x.oninput = x.onchange = x.onpropertychange = function() { sv(s, x.value) }; return x; }