cssfullcalendarmedia-queriesfullcalendar-schedulerfullcalendar-3

Full Calendar Default View


Since Full Calendar is not really suitable for smaller screen I'm trying to change the "default view" of the full calendar according to the width size of the screen.

I'm trying to implement that with this line code:

defaultView: (function () { 
  if ($(window).width() >= 768) { 
    return defaultView = 'agendaDay'; 
  } else { 
  return defaultView = 'month'; 
  } 
})

It's working fine however you have to refresh the browser every time to view the changes.

I tried windowResize function but no Luck. Any help would really be appreciated. Looking for sulotion without refresh the page. Thanks in advance.


Solution

  • As of v5, defaultView was renamed to intialView so this works:

    initialView: window.innerwidth >= 768 ? 'agendaDay' : 'month',