【问题标题】:In fullCalendar change slotDuration without page reloading在 fullCalendar 中更改 slotDuration 而无需重新加载页面
【发布时间】:2014-11-12 08:16:23
【问题描述】:

使用 fullcalendar 我需要根据其他条件更改 slotDuration 参数,而无需重新加载页面:

在一种情况下我会这样做

$('#calendar').fullCalendar('option', 'slotDuration', '00:15:00');

其他情况

$('#calendar').fullCalendar('option', 'slotDuration', '00:30:00');

但看起来它不起作用,因为我总是看到带有 slotDuration=30(2 个插槽)分钟的 fullcalendar,因为它在初始化时被调用。

如果有办法呢?

【问题讨论】:

    标签: javascript fullcalendar


    【解决方案1】:

    现在,您可以设置dynamically 无需 破坏 calendar

    $('#cc-calendar')
      .fullCalendar('option','slotDuration','00:10:00');
    

    在这里,我们使用fullcalendarDynamically get/set Options 功能。

    欲了解更多信息,请查看:https://fullcalendar.io/docs/utilities/dynamic_options/

    祝你好运。

    【讨论】:

    【解决方案2】:

    如您所见here,fullCalendar 仅允许在初始化后更改某些属性。您不需要重新加载页面,但需要销毁和初始化。

    所以:

    var calendarOptions = {
        defaultView: 'month', 
        editable: true,
        slotDuration: '00:45:00', 
        (...)
    }
    $('#calendar').fullCalendar(calendarOptions); //Init
    
    //And when you need to update any property
    
    calendarOptions.slotDuration = '00:15:00';
    $('#calendar').fullCalendar('destroy');
    $('#calendar').fullCalendar(calendarOptions);
    

    【讨论】:

      猜你喜欢
      • 2016-01-12
      • 2016-02-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-10
      • 2013-04-25
      • 2021-03-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多