gpt4 book ai didi

javascript - Dojo/Dijit - DateTextBox 隐藏了我的初始值

转载 作者:行者123 更新时间:2023-11-30 13:42:40 25 4
gpt4 key购买 nike

演示:http://3wcloud-com-provisioning-qa.appspot.com/testDijitDate

日历弹出窗口工作正常,让我选择一个新日期。但是当页面加载时,我看到日期 08/15/2009 闪了一下,然后就消失了。 CSS 或 JS 默认隐藏它有什么原因吗?

dojo.require("dijit.form.DateTextBox");
<link href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.3/dojo/resources/dojo.css" rel="stylesheet" />
<link href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.3/dijit/themes/claro/claro.css" rel="stylesheet" />
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.3/dojo/dojo.js" djConfig="parseOnLoad:true"></script>

<body class="claro">
<input id="startDate" name="startDate" dojoType="dijit.form.DateTextBox" required=true value="08/15/2009" />

我也在学习使用 FireBug。我可以通过浏览 DOM 找出值吗?

Firebug 显示:

<!-- <input type=text name=startDate size=10 value=""> -->
<div wairole="presentation" dojoattachevent="onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse" id="widget_startDate" class="dijit dijitReset dijitInlineTable dijitLeft dijitTextBox dijitDateTextBox" role="presentation" widgetid="startDate">
<div style="overflow: hidden;">
<div class="dijitReset dijitValidationIcon">
<br/>
</div>
<div class="dijitReset dijitValidationIconText">Χ</div>
<div class="dijitReset dijitInputField">
<input type="text" autocomplete="off" dojoattachpoint="textbox,focusNode" class="dijitReset" aria-valuenow="" aria-invalid="true" id="startDate" tabindex="0" aria-required="true" value="" />
<input type="text" style="display: none;" name="startDate" />
</div>
</div>
</div>

最佳答案

Dojo 在标记中专门使用 ISO8601/RFC3339 风格的日期。任何时候标记中需要日期值时,您都应该将其专门指定为 yyyy-mm-dd从 JavaScript 设置日期属性时,您应该使用 Date 对象:

dojo.require("dijit.form.DateTextBox");
dojo.addOnLoad(function() {
// make the date text box
var startDateTextBox = new dijit.form.DateTextBox({
value: new Date(2009, 7, 15)
}, "startDate");
});
<link href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.3/dojo/resources/dojo.css" rel="stylesheet" />
<link href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.3/dijit/themes/claro/claro.css" rel="stylesheet" />
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.3/dojo/dojo.js" djConfig="parseOnLoad:true"></script>

<body class="claro">
<input id="startDate" name="startDate" dojoType="dijit.form.DateTextBox" required=true value="2009-08-15" />

关于javascript - Dojo/Dijit - DateTextBox 隐藏了我的初始值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1371336/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com