开发者

Setting FullCalendar config values dynamically

As part of a development project using FullCalendar, I needed to be able to change the value of "slotMinutes" using a browser event (onClick). After a bit of struggle, I was able to find a way.

A) I have a "renderCalendar()" function that contains the jQuery function for building the calendar. Within this function is a setting for "slotMinutes", which I point to a variable initialized to 30.

;  slotTime = 30;

...

  function renderCalendar() {

      $('#calendar').fullCalendar({

          firstHour: 8,

          minTime: 6,

          maxTime: 18,

&开发者_如何学编程nbsp;         slotMinutes: parseInt(slotTime),

          defaultView: 'agendaWeek',

...

  });

B) My event handler function changes the slotTime value, destroys the current calendar, and re-runs the render function.

  function changeSlotTime(slottime) {

      slotTime = slottime;

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

      renderCalendar();

  }

C) The hard-fought battle with this change was understanding that the "slotMinutes" value MUST BE AN INTEGER. Note the "parseInt()" function in the example under section (A).


Current issue is described with comments by author of FullCalendar plugin: first link, second link


This should work..

function changeSlotTime(newTime) {
  $('#calendar').fullCalendar('options', 'slotTime', newTime
  renderCalendar();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜