diff --git a/src/aria/html/Select.js b/src/aria/html/Select.js
index 24cc81029..fca773769 100644
--- a/src/aria/html/Select.js
+++ b/src/aria/html/Select.js
@@ -32,6 +32,11 @@ Aria.classDefinition({
scope : this
});
+ this._chainListener(cfg.on, 'change', {
+ fn : this.__updateDataModel,
+ scope : this
+ });
+
this.$Element.constructor.call(this, cfg, context, line);
},
$prototype : {
diff --git a/test/aria/html/HTMLTestSuite.js b/test/aria/html/HTMLTestSuite.js
index 1a02df457..9064768fa 100644
--- a/test/aria/html/HTMLTestSuite.js
+++ b/test/aria/html/HTMLTestSuite.js
@@ -28,6 +28,7 @@ Aria.classDefinition({
this.addTests("test.aria.html.radioButton.RadioButtonTest");
this.addTests("test.aria.html.select.SelectTest");
this.addTests("test.aria.html.select.bodycontent.BodyContentTestCase");
+ this.addTests("test.aria.html.select.onchange.DataModelOnChangeTestCase");
this.addTests("test.aria.html.DisabledTraitTest");
this.addTests("test.aria.html.radioButton.ieBug.RadioButtonTestCase");
this.addTests("test.aria.html.textarea.TextAreaTestSuite");
diff --git a/test/aria/html/select/onchange/DataModelOnChangeTestCase.js b/test/aria/html/select/onchange/DataModelOnChangeTestCase.js
new file mode 100644
index 000000000..9430b9522
--- /dev/null
+++ b/test/aria/html/select/onchange/DataModelOnChangeTestCase.js
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2012 Amadeus s.a.s.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+Aria.classDefinition({
+ $classpath : "test.aria.html.select.onchange.DataModelOnChangeTestCase",
+ $extends : "aria.jsunit.TemplateTestCase",
+ $dependencies : ["aria.utils.Dom", "aria.html.Select", "aria.utils.SynEvents"],
+ $constructor : function () {
+ this.$TemplateTestCase.constructor.call(this);
+
+ this.data = {
+ selectedOption : "EURO",
+ onChangeOption : ""
+ };
+ this.setTestEnv({
+ template : "test.aria.html.select.onchange.DataModelOnChangeTpl",
+ data : this.data
+ });
+
+ },
+ $prototype : {
+ runTemplateTest : function () {
+
+ var document = Aria.$window.document;
+ var selectWidgets = this.testDiv.getElementsByTagName("select");
+
+ // we know there's only one
+ var selectWidget = selectWidgets[0];
+ this.assertEquals(selectWidget.selectedIndex, 0, "The selected Index should be %2 but was %1 ");
+
+ // to be nullified in the callback of the click action
+ this.selectWidget = selectWidget;
+ this.selectWidget.focus();
+
+ this.synEvent.type(this.selectWidget, "[down][down][enter]", {
+ fn : function () {
+ this.templateCtxt.$focus("justToFocusOut");
+ this.waitFor({
+ condition : function () {
+ return this.data.onChangeOption !== "";
+ },
+ callback : this.afterChange
+ });
+
+ },
+ scope : this
+ });
+ },
+
+ afterChange : function () {
+ this.assertEquals(this.data.selectedOption, "POUND", "Selected Option should be %2 but was %1");
+ this.assertEquals(this.data.onChangeOption, "POUND", "Changed Option should be %2 but was %1");
+ this.end();
+ }
+
+ }
+});
diff --git a/test/aria/html/select/onchange/DataModelOnChangeTpl.tpl b/test/aria/html/select/onchange/DataModelOnChangeTpl.tpl
new file mode 100644
index 000000000..18db36a62
--- /dev/null
+++ b/test/aria/html/select/onchange/DataModelOnChangeTpl.tpl
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2012 Amadeus s.a.s.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{Template {
+ $classpath : "test.aria.html.select.onchange.DataModelOnChangeTpl",
+ $wlibs : {
+ html : "aria.html.HtmlLibrary"
+ },
+ $hasScript : true
+}}
+
+{macro main()}
+
+ {var myStringOptions = ["EURO","FRANC SUISSE","POUND"]/}
+
+ {@html:Select{
+ options : myStringOptions,
+ bind : {
+ value : {
+ inside : data,
+ to : "selectedOption"
+ }
+ },
+ on :{
+ change:myFunc
+ }
+ }/}
+
+{/macro}
+{/Template}
diff --git a/test/aria/html/select/onchange/DataModelOnChangeTplScript.js b/test/aria/html/select/onchange/DataModelOnChangeTplScript.js
new file mode 100644
index 000000000..6d9448504
--- /dev/null
+++ b/test/aria/html/select/onchange/DataModelOnChangeTplScript.js
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2012 Amadeus s.a.s.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+Aria.tplScriptDefinition({
+ $classpath : "test.aria.html.select.onchange.DataModelOnChangeTplScript",
+ $prototype : {
+ myFunc : function () {
+ this.data.onChangeOption = this.data.selectedOption;
+ }
+ }
+});