dijit Form toJson 返回 dijit.form.DateTextBox 的空对象

发布于 2024-08-14 16:01:07 字数 279 浏览 5 评论 0原文

运行以下代码:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慈悲佛祖 2024-08-21 16:01:07

dijit.form.DateTextBoxvalue 属性是 Date 类型。这对于从 JavaScript 操作日期很有用,但默认情况下没有用于日期到 JSON 的序列化器。如果您希望获取用于序列化的小部件的值,请使用 dijit.form.DateTextBox.serialize(),这将为您提供字符串形式的值。

如果您在 dijit.form.Form 中使用 DateTextBox,则应在提交时进行序列化。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文