#9566 closed enhancement (fixed)
onChange hidden value is not set yet when onChange is triggered for currencyTextBox, dateTextBox, dropDownSelect, numberTextBox and timeTextBox
Reported by: | Ganeshpuri | Owned by: | Douglas Hays |
---|---|---|---|
Priority: | high | Milestone: | 1.4 |
Component: | Dijit - Form | Version: | 1.3.1 |
Keywords: | onChange trigger previous value | Cc: | Douglas Hays |
Blocked By: | Blocking: |
Description (last modified by )
When the onChange event is triggered the hidden value value (the one that is actually submitted) is not set yet. AJAX functions that are triggered onChange submit the previous value, not the actual one. This happens for a number of widget including currencyTextBox, dateTextBox, dropDownSelect, numberTextBox and timeTextBox.
Doug has proposed the solution:
Within dijit/form/_FormWidget.js, change:
if(this._onChangeActive){ this."onChange(newValue); }
to
if(this._onChangeActive){ setTimeout(dojo.hitch(this, "onChange", newValue), 0); }
This need to be applied to the embedded _FormWidget of DataGrid?.js too.
Here's an example that fails without the enhancement and works after applying them:
<div id="myDate"></div> <script type="text/javascript">
<![CDATA[ dojo.require("dojox.grid.DataGrid?"); dojo.require("dijit.form.DateTextBox?"); dojo.addOnLoad(function() {
new dijit.form.DateTextBox?({onChange: test}, dojo.byId("myDate"));
}); function test() {
alert(dijit.byId('myDate').domNode.childNodes[0].childNodes[2].childNodes[1].value);
} ]]>
</script>
Change History (12)
comment:1 Changed 12 years ago by
Description: | modified (diff) |
---|---|
Owner: | set to Douglas Hays |
Status: | new → assigned |
comment:2 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:3 Changed 12 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
This fix breaks breaks the onChange handling for dojox.form.DropDownSelect?.
comment:4 Changed 12 years ago by
Sorry - forgot to include the link:
http://archive.dojotoolkit.org/nightly/checkout/dojox/form/tests/test_DropDownSelect.html
That test case breaks with the fix for this bug. Rolling back revision [18972] fixes the test case.
comment:5 Changed 12 years ago by
comment:6 Changed 12 years ago by
comment:7 Changed 11 years ago by
comment:8 Changed 11 years ago by
comment:10 Changed 11 years ago by
Not sure - I'd ask bill. I just fixed the runner error where doh.is(NaN, NaN) broke comparing objects...
comment:11 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
ah - I'm the one who reopened this one...yeah - it's fixed now.
comment:12 Changed 10 years ago by
Component: | Dijit → Dijit - Form |
---|
(In [18972]) Fixes #9566. References #9531. Call onChange within a setTimeout/0 to allow processing to quiesce. Collapse rapid onChange calls to prevent browser overload.