dijit Form toJson 返回 dijit.form.DateTextBox 的空对象
运行以下代码:
dojo.toJson(formSearch.attr("value"));
似乎没有序列化 dijit.form.DateTextBox
控件的值。查看 Firebug,我可以看到 formSearch.attr("value"))
返回包含控件设置的值的适当 DOM 对象,但是当我尝试序列化它时,我得到像这样的东西:
{"startDate":{}}
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":{}}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
dijit.form.DateTextBox
的value
属性是 Date 类型。这对于从 JavaScript 操作日期很有用,但默认情况下没有用于日期到 JSON 的序列化器。如果您希望获取用于序列化的小部件的值,请使用 dijit.form.DateTextBox.serialize(),这将为您提供字符串形式的值。如果您在
dijit.form.Form
中使用DateTextBox
,则应在提交时进行序列化。The
value
attribute of adijit.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, usedijit.form.DateTextBox.serialize()
, which will give you the value as a string.If you use the
DateTextBox
in a or adijit.form.Form
, the serialization should happen for you on submit.