Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#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 Douglas Hays)

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 10 years ago by Douglas Hays

Description: modified (diff)
Owner: set to Douglas Hays
Status: newassigned

comment:2 Changed 10 years ago by Douglas Hays

Resolution: fixed
Status: assignedclosed

(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.

comment:3 Changed 10 years ago by Nathan Toone

Resolution: fixed
Status: closedreopened

This fix breaks breaks the onChange handling for dojox.form.DropDownSelect?.

comment:4 Changed 10 years ago by Nathan Toone

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 10 years ago by Douglas Hays

(In [19023]) References #9566. Fixed some automated tests that were assuming onChange would always fire synchronously.

comment:6 Changed 10 years ago by Douglas Hays

(In [19024]) References #9566. Fix tests/test_DropDownSelect.html to wait for onChange to fire

comment:7 Changed 10 years ago by bill

(In [19107]) Fix regressions in test_validate.html from [19023]:

  • syntax error and other errors causing test to hang on IE
  • made doh.is(NaN, NaN) work

Refs #9566 !strict.

comment:8 Changed 10 years ago by Nathan Toone

(In [19526]) Refs #9566 !strict fix runner.js so that it will fail if objects are different

comment:9 Changed 10 years ago by Douglas Hays

toonetown, I see several fixes went in. Is this fixed now?

comment:10 Changed 10 years ago by Nathan Toone

Not sure - I'd ask bill. I just fixed the runner error where doh.is(NaN, NaN) broke comparing objects...

comment:11 Changed 10 years ago by Nathan Toone

Resolution: fixed
Status: reopenedclosed

ah - I'm the one who reopened this one...yeah - it's fixed now.

comment:12 Changed 8 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.