问题
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