如何将Monthview中的未来日期数字设置为灰色,就像它们过去一样

时间:2014-10-28 03:01:34

标签: fullcalendar

我在Fullcalendar插件的Month视图中无法选择天数。当用户点击它们时,日期不会被选中,但我希望获得这些日期数字'在细胞的右上角,灰色'好像他们过去一样。我无法弄清楚如何。这是我迄今为止在dayRender函数中所拥有的:

dayRender: function (date, cell) {
  var today = new Date();
  var LeadDt = moment(new Date(tempLead));
  LeadDt = LeadDt.subtract("days", 1);
  var dDate = moment(new Date(date));

  if (LeadDt.diff(dDate) > -1 )
  {
    $(cell).addClass('ui-state-disabled');
    $(cell).closest('td').addClass('unselectable');
    $(cell).push('fc-other-month');// attempt #1 to add fc-other-month class to td - fail
    $(cell).closest("td[data-date='" + moment(date).format("YYYY-MM-DD") + "']").addClass('fc-other-month'); // attempt #2 to add fc-other-month class to td - fail
  }
}, 

任何人都可以让我知道如何实现这一目标吗?提前谢谢。

1 个答案:

答案 0 :(得分:0)

我最终找到了相应的data-date属性并在那里添加了类:

 if (LeadDt.diff(dDate) > -1 )
 {
  cell.addClass('ui-state-disabled');
  cell.closest('td').addClass('unselectable');
  $("td").find("td[data-date='" + moment(date).format("YYYY-MM-DD") + "']").addClass('fc-other-month');
 }
相关问题