From b9aac0ada7d26741639aecf2527709c0e1ae5ede Mon Sep 17 00:00:00 2001 From: Elliott Sprehn Date: Thu, 15 Jan 2015 15:03:44 -0800 Subject: [PATCH] Add two way data binding. All reflected attributes two way bind on SkyElement, so now doing is enough to get two way binding on the value attribute so users doing will get the inputValue property updated as the user types. R=abarth@chromium.org, ojan@chromium.org Review URL: https://codereview.chromium.org/850383002 --- examples/widgets/index.sky | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/widgets/index.sky b/examples/widgets/index.sky index d4e55c0d10..98b0ab47a4 100644 --- a/examples/widgets/index.sky +++ b/examples/widgets/index.sky @@ -25,7 +25,10 @@ } - + + +
value = {{ inputValue }}
+
Button @@ -37,7 +40,8 @@
Checkbox
highlight: {{ myCheckbox.highlight }}
checked: {{ myCheckbox.checked }}
-
Checkbox, default checked.
+
Checkbox, default checked.
+
checked: {{ checked }}
@@ -61,6 +65,8 @@ module.exports = class extends SkyElement { this.myCheckbox = null; this.myText = null; this.clickCount = 0; + this.inputValue = "Ready"; + this.checked = false; } attached() { this.myButton = this.shadowRoot.getElementById('button'); @@ -70,7 +76,8 @@ module.exports = class extends SkyElement { } handleClick(event) { this.clickCount++; - this.myText.value = "Moar clicking " + this.clickCount; + this.checked = !this.checked; + this.inputValue = "Moar clicking " + this.clickCount; } }.register();