Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set Fullcalendar options dynamically

How can I set the minTime and maxTime options after the calendar is created?

I tried the following, which doesn't work:

$('#calendar').fullCalendar('option', 'minTime', 7);
$('#calendar').fullCalendar('render');
like image 706
Bobby B Avatar asked Nov 17 '12 15:11

Bobby B


People also ask

How do I create a dynamic event in Fullcalendar?

although it is not specified on the fullcalender site, it is necessary to assign a value to the "allday" parameter to be able to add new events dynamically. If you set this value to "false", it will not add the event to the AllDay row. If you do "true" it will add to the AllDay row. Show activity on this post.

How do I set events in Fullcalendar?

Here is an example of how to specify an array of events: var calendar = new Calendar(calendarEl, { events: [ { title : 'event1', start : '2010-01-01' }, { title : 'event2', start : '2010-01-05', end : '2010-01-07' }, { title : 'event3', start : '2010-01-09T12:30:00', allDay : false // will make the time show } ] });

How do I select multiple dates in Fullcalendar?

Detect when the user clicks on dates or times. Give the user the ability to select multiple dates or time slots with their mouse or touch device. Allows a user to highlight multiple days or timeslots by clicking and dragging.

How do I change colors in Fullcalendar?

You can change the color of all events on the calendar like so: var calendar = new Calendar(calendarEl, { events: [ // my event data ], eventColor: '#378006' }); You can use any of the CSS color formats such #f00 , #ff0000 , rgb(255,0,0) , or red .


4 Answers

I don't know if it is still relevant but I can change the options with the following statement:

example for selectable:

$('#calendar').fullCalendar('getView').calendar.options.selectable = false;
$('#calendar').fullCalendar('render'); // rerender to see visual changes

Though it's not dynamically but at least you don't have to destroy the whole calendar and refetch your events :-)

like image 101
the hand of NOD Avatar answered Oct 10 '22 19:10

the hand of NOD


This functionality has been officially release in v2.9.0: http://fullcalendar.io/docs/utilities/dynamic_options/

like image 37
arshaw Avatar answered Oct 10 '22 18:10

arshaw


This way you can change as many calendar options you like:

// save the calendar options in a variable
var calendarOptions = $('#calendar')
     .fullCalendar('getView')
     .options;

// make your changes to the calendar options
// I wanted to change the slotDuration
calendarOptions.slotDuration = '00:20:00';

// destroy the calendar
$('#calendar')
     .fullCalendar('destroy');

//Lets load the calendar with the new options
$('#calendar')
     .fullCalendar(calendarOptions);

Hope this helps. Thanks.

like image 4
Aakash Avatar answered Oct 10 '22 18:10

Aakash


Can't be done without recreating the calendar.

Update: Can be done in v 2.9: See below

like image 4
Bobby B Avatar answered Oct 10 '22 19:10

Bobby B