在完整日历中的日期渲染上显示加号图标
Display Plus icon on day render in full calendar
我的默认视图是完整日历中的月视图
我在日渲染事件的每一天都显示一个加号图标,但是加号图标对所有日期和即将到来的日期可见
我只想在启用日期或即将到来的日期显示加号图标,而不是在过去的日期,请帮助我做到这一点。
下面是我的日历脚本
<script type="text/javascript">
$(document).ready(function() {
/* initialize the calendar
-----------------------------------------------------------------*/
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
dayRender: function (date,cell) {
cell.prepend('<i class="fa fa-plus" aria-hidden="true"></i>');
},
selectable: true,
selectHelper: true,
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
<?php if(!empty($calendar)){ foreach ($calendar as $schdate){
$dte = date('Y-m-d', strtotime($schdate['schedule_date'])); ?>
{
title: '<?php echo $schdate['schedule_title']; ?>',
start: '<?php echo $dte; ?>'
},
<?php } } ?>
]
});
});
</script>
试试这个...
此 getDates() 函数用于检索当前日期
function getDates()
{
var date = new Date();
var cellYear = date.getFullYear();
var cellMonth = (date.getMonth() + 1 <10)?'0'+(date.getMonth() + 1) : (date.getMonth() + 1);
var cellDay = (date.getDate()<10)?'0'+(date.getDate()):(date.getDate());
var newDate = cellYear+"-"+cellMonth+"-"+cellDay;
return newDate;
}
dayRender: function (date, cell) {
var cellYear = date.year();
var cellMonth = (date.month() + 1 <10)?'0'+(date.month() + 1) : (date.month() + 1);
var cellDay = (date.date()<10)?'0'+(date.date()):(date.date());
var newDate = cellYear+"-"+cellMonth+"-"+cellDay;
if(newDate >= getDates()){
cell.append('<i class="fa fa-plus" aria-hidden="true"></i>');
}
},
我的默认视图是完整日历中的月视图 我在日渲染事件的每一天都显示一个加号图标,但是加号图标对所有日期和即将到来的日期可见
我只想在启用日期或即将到来的日期显示加号图标,而不是在过去的日期,请帮助我做到这一点。
下面是我的日历脚本
<script type="text/javascript">
$(document).ready(function() {
/* initialize the calendar
-----------------------------------------------------------------*/
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
dayRender: function (date,cell) {
cell.prepend('<i class="fa fa-plus" aria-hidden="true"></i>');
},
selectable: true,
selectHelper: true,
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
<?php if(!empty($calendar)){ foreach ($calendar as $schdate){
$dte = date('Y-m-d', strtotime($schdate['schedule_date'])); ?>
{
title: '<?php echo $schdate['schedule_title']; ?>',
start: '<?php echo $dte; ?>'
},
<?php } } ?>
]
});
});
</script>
试试这个...
此 getDates() 函数用于检索当前日期
function getDates()
{
var date = new Date();
var cellYear = date.getFullYear();
var cellMonth = (date.getMonth() + 1 <10)?'0'+(date.getMonth() + 1) : (date.getMonth() + 1);
var cellDay = (date.getDate()<10)?'0'+(date.getDate()):(date.getDate());
var newDate = cellYear+"-"+cellMonth+"-"+cellDay;
return newDate;
}
dayRender: function (date, cell) {
var cellYear = date.year();
var cellMonth = (date.month() + 1 <10)?'0'+(date.month() + 1) : (date.month() + 1);
var cellDay = (date.date()<10)?'0'+(date.date()):(date.date());
var newDate = cellYear+"-"+cellMonth+"-"+cellDay;
if(newDate >= getDates()){
cell.append('<i class="fa fa-plus" aria-hidden="true"></i>');
}
},