HTML
xxxxxxxxxx
1
<div class="calendar" id="calendar"></div>
CSS
1
1
JS
xxxxxxxxxx
1
const events = [
2
{
3
summary: 'JS Conference',
4
start: {
5
date: Calendar.dayjs().format('DD/MM/YYYY'),
6
},
7
end: {
8
date: Calendar.dayjs().format('DD/MM/YYYY'),
9
},
10
color: {
11
background: '#cfe0fc',
12
foreground: '#0a47a9',
13
},
14
customAttribute: 'test custom attribute'
15
},
16
];
17
18
const newEventAttributes = (e) => {
19
e.newAttribute = 'test';
20
return e;
21
}
22
23
const calendarElement = document.getElementById('calendar');
24
const calendarInstance = new Calendar(calendarElement, {newEventAttributes: newEventAttributes});
25
calendarInstance.addEvents(events);
26
27
calendarElement.addEventListener('addEvent.mdb.calendar', (e) => {
28
console.log(e.event);
29
})
30
31
calendarElement.addEventListener('editEvent.mdb.calendar', (e) => {
32
console.log(e.event);
33
})
Console errors: 0