refetchEvents不更新日历

时间:2017-11-06 11:42:00

标签: javascript jquery angularjs fullcalendar

每次使用新的<h1>对象单击balance时,calander.fullCalendar('refetchEvents')都不会刷新。日历视图中的月份不会更改。

var app=angular.module('myApp',[]);
     app .controller('myController', ['$scope', '$http', function ($scope, $http) {

      $scope.init=function(){
      $scope.LeaveBalance=[
            {
                'month':"JAN",
                'pd':06,
                'op':04,
                'defaultDate':'2017-01-05'
            },
            {
                'month':"FEB",               
                'pd':06,
                'op':04,
                'defaultDate':'2017-02-05'
            },
            {
                'month':"MAR",
                'pd':06,
                'op':04,
                'defaultDate':'2017-03-05'
            },           
            {
                'month':"DEC",
                'pd':06,
                'op':04,
                'defaultDate':'2017-12-05'
            }          

        ];
      }

      $scope.myfunc =function(balance){      
          $scope.showLeaveBalance(balance)      
      }   

             $scope.showLeaveBalance =function(balance){
            calendar= $('#fullCalendar').fullCalendar({
            defaultDate: balance.defaultDate,
            editable: true,
            eventLimit: true,
            events: [
                 {
                     title: 'SL',
                    start: '2017-10-01',
                   // specialevent:'2017-10-15'
                },              
                {                   
                    title: 'SL',
                    start: '2017-10-28',
                     //specialevent:'2017-10-18'
                 }
            ]
           });    
        calendar.fullCalendar('refetchEvents')

      }

      }])

我的小提琴不起作用https://jsfiddle.net/shwwL2z1/2/但我已经正确地更新了所有内容。任何人都可以检查它吗?

2 个答案:

答案 0 :(得分:0)

.apply

了解更多详情click

答案 1 :(得分:0)

得到解决方案:

 $('#fullCalendar').fullCalendar({
            defaultDate: balance.defaultDate,
            editable: true,
            eventLimit: true,
            //weekends:false,
            events: [
                {
                    title: balance.title,
                    start: balance.startDate,
                   // specialevent:'2017-10-15'
                },              
                {                   
                    title: balance.title,
                    start: balance.startDate,
                    //specialevent:'2017-10-18'
                }
            ]
        });      
         $('#fullCalendar').fullCalendar('gotoDate', balance.defaultDate);

添加$('#fullCalendar').fullCalendar('gotoDate', balance.defaultDate);可以更新日期,月份和年份。