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

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

报告相同问题?

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装