我正在尝试根据第一个日历的更改来更新第二个日历。我已经找到功能calendar.view.activeStart;和calendar.view.type;这给了我开始日期和日历类型。我可以使用changeView();第一次加载时更新第二个日历的类型。但是日期格式我无法使用(2019年6月10日星期一格林尼治标准时间+0200(欧洲中部夏令时))。我如何使用calendar.view获取日期以及如何更新日期每次更改都有第二个日历。
这是我正在使用的代码。
var viewType = '';
var viewDate = '';
document.addEventListener('DOMContentLoaded', function() {
var Calendar = FullCalendar.Calendar;
var calendarEl = document.getElementById('calendar');
var calendar = new Calendar(calendarEl, {
locale: 'nl',
weekNumbers: true,
defaultDate: standaarddatum,
nowIndicator: true,
height: 500,
businessHours: true,
editable:true,
droppable: true,
selectable:true,
unselectAuto:true,
plugins: [ 'interaction', 'dayGrid', 'timeGrid', 'list' ],
themeSystem: 'bootstrap',
header: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,listYear'
},
allDaySlot: false,
defaultView: 'timeGridWeek',
events: {
url: 'load_select.php',
method: 'POST',
extraParams: function() {
return {
cursus_id:localStorage.getItem("cursus_select"), evenement_id:localStorage.getItem("evenement_select"), locatie_id:localStorage.getItem("locatie_select"), trainer_id:localStorage.getItem("trainer_select")
};
},
failure: function() {
alert('er zijn geen cursussen met deze combinatie!');
localStorage.setItem("cursus_select", '0');
localStorage.setItem("evenement_select", '0');
localStorage.setItem("locatie_select", '0');
localStorage.setItem("trainer_select", '0');
calendar.refetchEvents()
$('#cursusselect').val('');
$('#evenementselect').val('');
$('#locatieselect').val('');
$('#trainerselect').val('');
}
},
});
calendar.render();
viewDate = calendar.view.activeStart;
viewType = calendar.view.type;
});
//TWEEDE
document.addEventListener('DOMContentLoaded', function() {
var Calendar = FullCalendar.Calendar;
var calendarEl = document.getElementById('calendar10');
var calendar10 = new Calendar(calendarEl, {
locale: 'nl',
weekNumbers: true,
defaultDate: standaarddatum,
nowIndicator: true,
height: 500,
businessHours: true,
editable:true,
droppable: true,
selectable:true,
unselectAuto:true,
plugins: [ 'interaction', 'dayGrid', 'timeGrid', 'list' ],
themeSystem: 'bootstrap',
header: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,listYear'
},
allDaySlot: false,
defaultView: 'timeGridWeek',
events: {
url: 'load_select.php',
method: 'POST',
extraParams: function() {
return {
cursus_id:localStorage.getItem("cursus_select10"), evenement_id:localStorage.getItem("evenement_select10"), locatie_id:localStorage.getItem("locatie_select10"), trainer_id:localStorage.getItem("trainer_select10")
};
},
failure: function() {
alert('er zijn geen cursussen met deze combinatie!');
localStorage.setItem("cursus_select", '0');
localStorage.setItem("evenement_select", '0');
localStorage.setItem("locatie_select", '0');
localStorage.setItem("trainer_select", '0');
calendar10.refetchEvents()
$('#cursusselect10').val('');
$('#evenementselect10').val('');
$('#locatieselect10').val('');
$('#trainerselect10').val('');
}
},
});
calendar10.render();
calendar10.changeView(viewType, viewDate);
});
答案 0 :(得分:1)
它与gotoDate()一起使用;不是changeView();