2

I have a requirement where fullcalendar jquery plugin should be used. But I need to customize it. Like, I need to change the position of buttons of (day/month/week)view to the extreme left of the screen. When I tried to modify the fullcalendar.js I could see that it could move only to the right/left of the calendar. Not beyond that. I need to have those buttons in the left as in the sidebar of a page. Is it possible?? Or is there any other options for it??

I imagine that one way to go would be to create the buttons on my own and wire them into the Fullcalendar widget. But I'm not a jquery pro, and I'd prefer to try something simpler. Thanks.

2
  • 1
    You might try CSS instead of the fullcalendar.js. position: fixed; left: 0; aligns elements to the browser chrome. Commented Oct 27, 2012 at 14:03
  • Yes.. but that will aligns it in the left of the screen. But it is displaying as one row.. I need to display as list. So my requirement is like, There will be a button/link in the sidebar as "Calendar" and when you click on it, it would expand the available views of the calendar as lists.
    – rubyist
    Commented Oct 27, 2012 at 14:10

3 Answers 3

4

A simple and quick solution is to leave the plugin JS alone, and simply hide the built in buttons and add your own where you want them.

In your click handler for your buttons you trigger a click on the plugin button associated. It is as simple as inspecting the class of each button in browser console html view and adding to the code I started

Example

/* quick hide with script for a test, best done with css */
$('.fc-header-right').hide();

$('#myWeekViewButton').click(function(){
    $('.fc-button-agendaWeek').click();
});

This tests well in browser console on demo site

0
2

First, you can remove the day/month/week buttons from the header definition of your FullCalendar init. Next, you can use a function similar to the following to wire your custom buttons to do the view-switching operations:

function switchView(viewName) {
  $('#calendar').fullCalendar('changeView', viewName);
}

Let me know if this helps!

0
1

You can use de presets for headerToolbar

var calendar = new FullCalendar.Calendar(calendarEl, {
        headerToolbar: {
            center: 'dayGridMonth,timeGridFourDay'
        },.....

https://fullcalendar.io/docs/custom-view-with-settings

1
  • This is the best answer for version 5+. It will look something like this if you need buttons left and right: headerToolbar: { left: 'prev', center: 'title', right: 'next' },
    – Wak
    Commented May 18, 2022 at 18:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.