Framework7 datepicker modify events after initializing

风流意气都作罢 提交于 2020-01-06 15:25:12

问题


Hello Framework7 team,

How do we modify (renew) the events after initializing for example on a month change (onMonthYearChangeStart) ?

var today = new Date();
var weekLater = new Date().setDate(today.getDate() + 7);

var calendarEvents = myApp.calendar({
input: '#calendar-events',
dateFormat: 'M dd yyyy',
events: {
  from: today,
  to: weekLater
}
});

Kind regards, Mario


回答1:


I ended up looping through the events and added/removed classes to the date object like below: So with every month change I called the following script. I also used a minus and a plus class to get red and green dots.

eventsPlusDataValues = dataSet.map(function(a) {
    if(a.hasValue && a.value > 0)$("[data-date="+a.startDate+"]").addClass('picker-calendar-day-has-events').removeClass('picker-calendar-day-has-eventsMinus').addClass('picker-calendar-day-has-eventsPlus');
    if(a.hasValue && a.value < 0)$("[data-date="+a.startDate+"]").addClass('picker-calendar-day-has-events').removeClass('picker-calendar-day-has-eventsPlus').addClass('picker-calendar-day-has-eventsMinus');
    return a.startDate;
});

It is a while back so I hope I did not forget something.



来源:https://stackoverflow.com/questions/38128057/framework7-datepicker-modify-events-after-initializing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!