我有一个显示日历,只有52个星期内当天在道场回来,我使用dijit/Calendar
为同一的要求,能有人帮我在dijit的日历显示从当天只有52个星期前提供光。
目前我使用的data-dojo-props
这是在日历只禁止周末。
<div id="mycal" data-dojo-attachpoint="mycal"
data-dojo-type="dijit.calendar"
data-dojo-props="isDisabledDate:dojo.date.locale.isWeekend">
</div>
这是如此简单,你要做的是在有计划的方式,
创建日历的dijit,然后通过检查都显示卡视图的日子>或此改变其isDisabledDate
功能是工作日:如下
return dojoDate.difference(date, new Date(), "day") > disable_before_days || locale.isWeekend(date) ;
见工作片断如下:
require(["dojo/parser",
"dijit/Calendar",
"dijit/registry",
"dojo/date",
"dojo/date/locale",
"dojo/ready",
"dojo/domReady!"
], function(parser, Calendar, registry, dojoDate, locale, ready){
disable_before_days = 52;
ready(function(){
//var calendar = registry.byId("mycal");
var calendar = new Calendar({
value: new Date(),
isDisabledDate:function(date, localString){
return dojoDate.difference(date, new Date(), "day") > disable_before_days
|| locale.isWeekend(date)
|| date > new Date() ;
}
}, "mycal");
});
});
html, body {
height: 100%;
padding: 0;
margin: 0;
font-family: Lucida Sans,Lucida Grande,Arial !important;
font-size: 13px !important;
background: white;
color: #333;
}
#mycal .dijitCalendarDisabledDate {
background-color: #333;
text-decoration: none;
}
#mycal .dijitCalendarContainer {
margin: 25px auto;
}
<link href="https://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojox/calendar/themes/claro/Calendar.css" rel="stylesheet"/>
<link href="https://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dijit/themes/claro/claro.css" rel="stylesheet"/>
<script type="text/javascript">
dojoConfig = {
isDebug: true,
async: true,
parseOnLoad: true
}
</script>
<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
<body class="claro">
<div id="mycal" ></div>
</body>