【问题标题】:How to dynamically change event sources?如何动态更改事件源?
【发布时间】:2011-09-21 00:51:38
【问题描述】:

我正在使用 jQuery FullCalendar 插件。我想最初将带有事件的日历加载为数组。我这样做是这样的:

events: <%= Model.Events %>

或

eventSources: [{
                 events: <%= Model.Events %>
              }]

两种方式都可以正常工作。我正在使用 MVC 3.0,&lt;%= Model.Events %&gt; 返回 JSON 格式的事件数组。

我只想将事件数组用于日历的初始加载。后来,每次需要获取事件时,我都希望使用 url '/Calendar/Events' 加载我的事件。

如何实现?

我在viewDisplay 回调中尝试了addEventSource/removeEventSource 的不同场景,但对我来说没有任何效果。

【问题讨论】:

  • 你搞定了吗?下面的答案不起作用。 refectchEvents() 不起作用。

标签: events dynamic fullcalendar


【解决方案1】:

.fullCalendar( {

  eventSources : [ {
    url : '/Calendar/Events',
    type : 'GET'
  } ],

  viewDisplay : function( event ) {
     // assuming this will point to the full calendar,
     // might have to do something silly like
     // $( '#myCal' ).fullCalendar( 'refetchEvents' );
     this.refetchEvents();
  }
} );

【讨论】:

  • 你有这方面的工作例子吗? refectchEvents() 对我不起作用。
猜你喜欢
  • 2020-11-30
  • 1970-01-01
  • 2020-02-01
  • 2018-10-19
  • 2023-03-22
  • 1970-01-01
  • 1970-01-01
  • 2018-08-02
  • 2017-08-18
相关资源
最近更新 更多