2 回答
TA贡献1946条经验 获得超3个赞
由于您使用的是 fullCalendar 版本 4,它不再被编写为 jQuery 插件,因此无法使用 jQuery 语法来访问这些方法。相反,只需引用您的calendar变量(它可能需要在您的应用程序中具有广泛的范围 - 全局或易于通过其他方式访问)。您会注意到现有代码在调用calendar.render();.
此外,在“getView”方法的特定情况下,这已被简单地替换view为引用当前视图的属性。
例如(见最后一行):
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [ 'timeGrid', 'dayGrid' ],
defaultView: 'timeGridWeek',
height: 700,
locale: 'pt',
allDaySlot: false,
handleWindowResize: true,
events: [
{
title: 'Teste1', // a property!
start: '2019-07-23 16:00',
end: '2019-07-23 17:00',
backgroundColor: '#fcba03',
borderColor: '#fcba03',
}
]
});
calendar.render();
var vw = calendar.view; //get the current view
TA贡献1801条经验 获得超8个赞
**Create a config variable like below in js**
uiConfig = {
calendar: {
height: 450,
editable: true,
eventClick: alertEventOnClick,
eventDrop: alertOnDrop,
eventResize: alertOnResize,
eventRender: eventRender
}
};
**defines the above methods in js file**
alertEventOnClick = function (date, jsEvent, view) {}
alertOnDrop = function (date, jsEvent, view) {}
alertOnResize = function (date, jsEvent, view) {}
eventRender = function (date, jsEvent, view) {}
**and in html add below lines of code**
<div ui-calendar="uiConfig.calendar" id="myCalendar" calendar-watch-event="extraEventSignature(event)"
calendar="myCalendar" data-ng-model="eventSources">
</div>
**The Following code is another way of accessing calendar**
$('#myCalendar').fullCalendar({
eventClick: function(event, element) {
event.title = "CLICKED!";
$('#calendar').fullCalendar('updateEvent', event);
}
});
**where Mycalender should be added in HTML like below**
<div ui-calendar="uiConfig.calendar" id="myCalendar"
calendar="myCalendar" data-ng-model="eventSources">
</div>
添加回答
举报