views:

317

answers:

1

Running the following code:

dojo.toJson(formSearch.attr("value"));

Appears to not serialize the value of dijit.form.DateTextBox controls. Looking in Firebug, I can see that formSearch.attr("value")) returns the appropriate DOM object that contains the value that the control is set to, but when I try to serialize it, I get something like:

{"startDate":{}}
+1  A: 

The value attribute of a dijit.form.DateTextBox is of type Date. This is useful to manipulate Dates from JavaScript, but by default there is no serializer for Dates to JSON. If you wish to get the value of the widget for serialization, use dijit.form.DateTextBox.serialize(), which will give you the value as a string.

If you use the DateTextBox in a or a dijit.form.Form, the serialization should happen for you on submit.

peller
You are right that it is serialized on the form submit, but I wanted to xhr POST as JSON because I was having issues with other components and their values (http://stackoverflow.com/questions/1908121/value-of-dojox-checkedmultiselect-not-being-posted-with-dojo-xhrpost). But this makes sense... So thanks for the answer.
Kitson