From ca70f18a62a2a2b5670be132361e3a3f5907d920 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 18 May 2012 17:12:37 -0700 Subject: Fixing radio control in the PI. Signed-off-by: Nivesh Rajbhandari --- js/components/radio.reel/radio.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'js/components/radio.reel/radio.js') diff --git a/js/components/radio.reel/radio.js b/js/components/radio.reel/radio.js index c661ec11..cec4f52e 100755 --- a/js/components/radio.reel/radio.js +++ b/js/components/radio.reel/radio.js @@ -62,7 +62,7 @@ exports.RadioGroup = Montage.create(Component, { { value:function(radio) { - radio.element.setAttribute("name", this.name); + radio.radioField.setAttribute("name", this.name); radio.addEventListener("change", this, false); this.radios.push(radio); } @@ -104,6 +104,14 @@ exports.Radio = Montage.create(Component, { value: null }, + labelField: { + value: null + }, + + radioField: { + value: null + }, + _checked: { enumerable: false, value: false @@ -140,13 +148,13 @@ exports.Radio = Montage.create(Component, { { this._valueSyncedWithInputField = true; this._wasSetByCode = false; - this.checked = this.element.checked; + this.checked = this.radioField.checked; } }, handleClick: { value: function() { this._wasSetByCode = false; - this.checked = !this.element.checked; + this.checked = !this.radioField.checked; } }, @@ -154,7 +162,7 @@ exports.Radio = Montage.create(Component, { value: function() { if(!this._valueSyncedWithInputField) { - this.element.checked = this._checked; + this.radioField.checked = this._checked; } this._valueSyncedWithInputField = false; } @@ -163,15 +171,13 @@ exports.Radio = Montage.create(Component, { prepareForDraw: { value: function() { if (this.label !== null) { - var b = document.createElement("label"); - b.innerHTML = this.label; - this.element.appendChild(b); - b.addEventListener("click", this, false); + this.labelField.innerHTML = this.label; } + this.element.addEventListener("click", this, false); if (this.group !== null) { this.group.addRadio(this); } - this.element.addEventListener("change", this, false); + this.radioField.addEventListener("change", this, false); } } -- cgit v1.2.3