如何直接在表单中使用 dijit.Calendar(而不是作为弹出窗口)
我希望将 dijit.form.Calendar 直接嵌入到我的 dojo 表单中,而不是显示为弹出窗口(如 dijit.form.DateTextBox 提供的;这是因为表单已经是一个下拉选择器,只选择一个日期比再次单击文本框要自然得多)
最简单的方法是什么?我不介意文本框是否仍然出现并且可编辑(尽管这不是必需的) - 但 dijit.Calendar 文档明确指出您不能将其用作表单元素,因为它不提供输入。
I'd like to have a dijit.form.Calendar embedded directly in my dojo form, rather than appearing as a popup (as dijit.form.DateTextBox provides; this is because the form is already a dropdown selector and just choosing a date would be much more natural than having to click again on the text box)
What's the easiest way to do this? I don't mind if the text box still appears and is editable (although that's not a requirement) - but the dijit.Calendar
docs say explicitly that you can't use it as a form element because it doesn't provide an input.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先查看 http://docs.dojocampus.org/dijit/Calendar
您是正确的执行日历不会产生表单输入。我是这样做的。本质上,当用户单击日期时,我们通过保存稍后使用的值来响应单击。
First Check out http://docs.dojocampus.org/dijit/Calendar
You are correct that this implementation of the calendar does not produce a form input. Here's how I have done it. Essentially when the user clicks a date we respond to the click by saving off the value to be used later.
我实际上所做的是创建一个新的 dijit 小部件,将值存储在隐藏的文本字段中。基本思想遵循 javascript 和模板,尽管 完整实现 更加复杂,因为它还包括使用也显示时间的自定义日历小部件。
此版本已被删除且未进行测试。我发现正确处理传递的约束以及反馈到输入的值并不是一项简单的任务。此外
widgetsInTemplate
对于正确加载日历小部件至关重要:然后模板大致如下所示:
What I actually did was to create a new dijit widget that stores the value in a hidden text field. The basic idea follows in javascript and template, although the full implementation is more complex as it also includes using a custom calendar widget that also displays the time.
This has been cut down and not tested in this incarnation. I found that handling the constraints being passed through correctly and the value being fed back to the input was not a trivial task. Also
widgetsInTemplate
was critical to get this to load the calendar widget properly:Then the template looks roughly like this: