dongqiu5184 2013-06-03 17:16
浏览 95
已采纳

通过ajax调用Jquery完整日历事件

i am very much stacked to render events by updating my database entry. Initially, I have successfully rendered events through;

I have event array as:

{title: 'Available', start: new Date(2013, m, 05, 09,50), end: new
 Date(2013, m, 05, 10,00), allDay: false},{title: 'Available', start:
 new Date(2013, m, 04, 00,20), end: new Date(2013, m, 04, 00,50),
 allDay: false}

Which will be rendered in calander through:

events:[<?php echo $events?>]

Upto this, code works good and renders the event as per required.

After prev, next button is clicked, i have to render the events by updating the database. That is something like this:

 $('.fc-button-next span').live('click', function() {
        var calandar = $('#calandar');
         $.ajax({
            url: 'fetchEvents',
            dataType: 'JSON',
            type: 'POST',
            success: function(doc) {
                calandar.fullCalendar('removeEvents',event),
               calandar.fullCalendar( 'renderEvent',doc.events);
               calandar.fullCalendar('rerenderEvent',doc.events);
            }
        });
});

Where "fetchEvents" returns the same event format as before but in JSON form, like:

"{title: 'Available', start: new Date(2013, m, 05, 09,50), end: new Date(2013, m, 05, 10,00), allDay: false}"

Dont know, how to render JSON event objects on next-click event. That is i have to render completely new events through ajax call. Please suggest.

Solved:

Instead of events i have built, i create JSON events as suggested by Lukasz Koziara as in his first suggestion so that each time calendar event occurs, it acquires the eventSource to fetch the events. JSON EVENT

[{"title":"Available","start":"2013-06-06 05:20:00","end":"2013-06-06 05:50:00","allDay":false}]

Instead of events, i made a ajax call with in eventSources to get this type of JSON EVENTS. This looks like:

 eventSources: [{
                    url: 'fetchEvents',
                    type: 'POST'
                }]

So that, when calander renders for the first time or next,previous or today buttons are clicked, calander it self fetches events as specified by eventSources.

  • 写回答

1条回答 默认 最新

  • douzhu3654 2013-06-04 08:02
    关注

    First suggestion: why not use one type of event source? For example use JSON feed - you can get events range by GET parameters start and end, so if you change month or view you can send from database appriopriate events.

    Second suggestion: if you necessarily need two types of event sources, try use addEventSource / removeEventSource

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch