John Davidson

javascript - Pass another parameter to Fulcalendar

0 comments
Message:


Here is the code, the "events: url," part of the code is coming through into my fullcalendar.js file and adds the events however I also want to add a list of users from json data like so users:'urlusers'


Will I have to edit the fullcalendar.js file and if so where can I add another parameter for the users.


$(document).ready(function() {
var calendar = $('#calendar').fullCalendar({
defaultView: 'agendaWeek',
minTime: "08:00:00",
maxTime: "20:00:00",
editable:false,
header:{
left:'prev,next today',
center:'title',

},
events: 'https://events.com/eventsjson',
users:'https://events.com/usersjson',
selectable:true,
selectHelper:true,
select: function(start, end, allDay)
{
var titlestart = $.fullCalendar.formatDate(start, "DD-MM-Y HH:mm:ss");


var r = confirm("Request Time " + titlestart);
if (r == true) {
event.preventDefault();
//Open dialog
var subject = 'Booking '+titlestart;
var emailBody = 'Create booking for '+titlestart
showDialog(titlestart);
} else {

}
},
});
});


My Answer:
function that initializes FullCalendar:

javascript
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');

var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'dayGridMonth',
events: [
{
title: 'Event 1',
start: '2022-01-01'
},
{
title: 'Event 2',
start: '2022-01-05'
}
]
});

calendar.render();
});


To pass another parameter to FullCalendar, you can simply add it to the options object when creating the calendar. For example, if you want to pass a custom parameter called `customParam` with a value of `true`, you can do so like this:

javascript
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'dayGridMonth',
events: [
{
title: 'Event 1',
start: '2022-01-01'
},
{
title: 'Event 2',
start: '2022-01-05'
}
],
customParam: true
});


You can then access this parameter within FullCalendar by using `calendar.getOption('customParam')`.

Rate this post

4 of 5 based on 1986 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us