Dav*_*ser 0 dojo popup dijit.form
我想直接在我的dojo表单中嵌入一个dijit.form.Calendar,而不是像弹出一样显示(如dijit.form.DateTextBox提供的;这是因为表单已经是一个下拉选择器而只是选择一个日期会比在文本框上再次点击更自然)
最简单的方法是什么?我不介意文本框是否仍然出现并且是可编辑的(虽然这不是必需的) - 但是dijit.Calendar文档明确表示你不能将它用作表单元素,因为它不提供输入.
首先查看http://docs.dojocampus.org/dijit/Calendar
你是对的,这个日历的实现不会产生表单输入.这是我如何做到的.基本上当用户点击日期时,我们通过保存稍后要使用的值来响应点击.
//This function is called from via a "dojo.addOnLoad"
//It creates the calendar and defines an event for "onValueSelected"
function initCalendar() {
dojo.declare("BigCalendar", dijit.Calendar, {
onValueSelected: function(date){calendarDateClicked(date);}
});
bigCalendar = dojo.byId("calendarEvents");
bigCalendar.setAttribute("dojoType", "BigCalendar");
dojo.parser.parse(bigCalendar.parentNode);
}
function calendarDateClicked(date) {
// Here you can either take the date and put in into a text box (maybe hidden?) or save it off into an internal variable that you can later use in an ajax call or however you see fit.
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4464 次 |
| 最近记录: |