The Scheduler uses visibleStart() and visibleEnd() to read the current visible range boundaries in events.load(). If you make changes to startDate and days these changes will only be applied when you call update() (or when the changes are applied automatically by Vue). It is not possible to read the new visibleStart() and visibleEnd() values before update.
For the various scenarios it works like this:
1. Changes made to the config object are merged and applied automatically at the end of the current event loop cycle. This is handled by Vue. This means that you are not able to read the new values in the same cycle. You'd have to postpone event loading until the next cycle:
next() {
Vue.set(this.config, "startDate", this.config.startDate.addMonths(1));
Vue.set(this.config, "days", this.config.startDate.daysInMonth());
var T = this;
setTimeout(function() {
T.loadEvents();
}, 0);
}
2. If you make changes directly to the DayPilot.Scheduler changes you can call the update() method first:
2.A
previous() {
this.scheduler.startDate = this.scheduler.startDate.addMonths(-1);
this.scheduler.days = this.scheduler.startDate.daysInMonth();
this.scheduler.update();
this.loadEvents();
},
This will apply the changes and update the Scheduler and then it will request a new data set from the specified URL. Two updates will be performed - the first update is complete (it changes the timeline) and the second update is partial (it only loads and renders the events).
2.B
Or you can load the events first and update the Scheduler once to apply all changes:
previous() {
var start = this.scheduler.startDate.addMonths(-1);
var days = start.daysInMonth();
var end = start.addDays(days);
DayPilot.Http.ajax({
url: "<myAPI>?start=" + start + "&end=" + end,
success: function(ajax) {
this.scheduler.update({
startDate: start,
days: days,
events: ajax.data
});
}
});
},
This approach (2.B) may seem more efficient as it only performs a single update but please note that it will be delayed until the events are loaded.
Generally, I'd recommend using the direct API to change the Scheduler properties and providing immediate feedback, with two updates (2.A).