从空月移动时不会出现事件

时间:2017-06-28 10:25:03

标签: fullcalendar

如果我从有活动的一个月搬到没有活动的一个月,然后再回来,我的活动就不会再出现了。在几个月的事件之间移动工作正常。我必须刷新页面才能让他们回来。这是我的代码,我只是看不出任何错误......

$("#datepicker").fullCalendar({
            header: {
                left:   'prev,next,cbRefresh',
                center: 'title',
                right:  ''
            },
            height:             750,
            firstDay:           1,
            weekNumbers:        true,
            editable:           false,
            eventLimit:         true,
            displayEventTime:   false,
            dayClick: function(seldate,jsEvent,view) {
                window.location.href="multiple?dt="+seldate.format();
            },
            eventClick: function(evt,jsEvent,view) {
                if(evt.id) {
                    window.location.href="details?id="+evt.id+"&dt="+evt.start.format();
                }
            },
            events: {
                    url:    servicePath+"calendar.php",
                    type:   'GET',
                    data:   function() {

                            var theDate=$("#datepicker").fullCalendar('getDate');
                            return {
                                t:      'load',
                                uid:    uid,
                                mon:    theDate.month()+1
                            }
                },
                error:  function(){
                    displayError("Events error: " +item.ErrorMessage);
                }
            },
            eventRender: function(evt,ele,view) {
                $(ele).each(function(){
                    $(this).attr("data-num",evt.start.format("YYYY-MM-DD"));
                    $(this).attr("data-worked",evt.worked);
                    $(".fc-title",this).attr("title",evt.activity);                     
                });
            },
            eventAfterAllRender: function(view) {

                if(view.name=="month") {

                    for(cDay=view.start.clone(); cDay.isBefore(view.end); cDay.add(1,'day')) {
                        var ttl=0;
                        var dateNum=cDay.format('YYYY-MM-DD');
                        $(".fc-event-container").find('.fc-event[data-num="'+dateNum+'"]').each(function(){

                            var currentWorked=$(this).attr("data-worked");
                            if(currentWorked) {
                                ttl+=parseInt(currentWorked);
                            }

                        });

                        //display the total and relevant buttons
                        if(ttl>0) {

                            var footer=$('.fc-day[data-date="'+dateNum+'"]').find(".fc-cell-footer");

                            $(footer).append('<a title="Delete all" class="btn btn-xs" href="delete?dt='+dateNum+'">'+
                                            '<span class="glyphicon glyphicon-trash"></span></a>'+
                                            '<a title="Copy" class="btn btn-xs" href="copy?dt='+dateNum+'">'+
                                            '<span class="glyphicon glyphicon-copy"></span></a>'+
                                            '<a title="List" class="btn btn-xs" href="list?dt='+dateNum+'">'+
                                            '<span class="glyphicon glyphicon-th-list"></span></a>');
                            $(footer).append('<span class="ttlHours">Hours: '+buildTime(ttl)+'</span>');
                        }

                    }

                }

            },
            dayRender: function(date,cell) {

                var theDate=moment(date).format("YYYY-MM-DD");

                $(cell).css("vertical-align", "bottom"); 
                $(cell).append('<div class="fc-cell-footer"></div>');
            },
            customButtons: {
                cbRefresh: {
                    text:   'Refresh',
                    click:  function() {
                        $("#datepicker").fullCalendar("destroy");
                        buildCalendar();
                    }
                }
            }

        });

甚至尝试将代码剥离回基础并且仍然无法正常工作。我确实知道'事件:数据'每次都被触发,因为我已将它设置为给我发电子邮件(在测试时)。

        $("#datepicker").fullCalendar({
            header: {
                left:   'prev,next,cbRefresh',
                center: 'title',
                right:  ''
            },
            height:             750,
            firstDay:           1,
            weekNumbers:        true,
            editable:           true,
            eventLimit:         true,
            displayEventTime:   false,

            events: {
                    url:    servicePath+"calendar.php",
                    type:   'GET',
                    data:   function() {

                            var theDate=$("#datepicker").fullCalendar('getDate');
                            return {
                                t:      'load',
                                uid:    uid,
                                mon:    theDate.month()+1
                            }
                },
                error:  function(){
                    displayError("Events error: " +item.ErrorMessage);
                }
            },
            customButtons: {
                cbRefresh: {
                    text:   'Refresh',
                    click:  function() {
                        $("#datepicker").fullCalendar("destroy");
                        buildCalendar();
                    }
                }
            }

        });

1 个答案:

答案 0 :(得分:0)

听起来您提供的网址会过滤日历应显示的事件。尝试简单的事情:

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
        UIApplicationState state = [application applicationState];
        if (state == UIApplicationStateActive)
            {
                //app is in foreground
                //the push is in your control
                UILocalNotification *localNotification = 
               [[UILocalNotification alloc] init];
               localNotification.userInfo = userInfo;
               localNotification.soundName = 
               UILocalNotificationDefaultSoundName;
               localNotification.alertBody = message;
               localNotification.fireDate = [NSDate date];
                [[UIApplication sharedApplication] 
               scheduleLocalNotification:localNotification];
            }
            else
            {
               //app is in background:
               //iOS is responsible for displaying push alerts, banner etc..
            }
        }

腓:

$("#calendar").fullCalendar({
        events: {
          url: 'getcalendar.php',
          type: 'POST',
          data: {
          },
          success : function(response){
            console.log("Updated events: "+response.length);
          }
        }
});