2017-10-30 6 views
0

FullCalendar를 사용 중이며 모달로 이벤트를 업데이트하려고합니다. 이벤트를 업데이트하려고하면 undefined의 'clone'속성을 읽을 수 없습니다. 자신의 문서에 명시된 바와 같이전체 calendar updateEvent입니다. 정의되지 않은 'clone'속성을 읽을 수 없습니다.

나는

이벤트가 이벤트에 대한 원본 이벤트 객체, 단순히 복원 된 객체 여야는 clientEvents 방법을 사용하고 있습니다. 원래 이벤트 객체는 eventClick과 같은 콜백 또는 clientEvents 메서드로 얻을 수 있습니다.

내 원본 이벤트를 가져 오려면 제출할 때이 오류가 계속 발생합니다.

initializeFullCalendar: function() { 

     var loc = $('#locationCodes').val(); 

     $('.autocomplete').keypress(function (key) { 

      if (key.charCode == 32 && $('.autocomplete').val().length >= 1) { return true }; 
      // if (key.charCode == 92 || key.charCode == 47 || key.charCode < 65) return false; 
     }); 

     $(document).tooltip({ 
      track: true, 
      hide: { effect: "explode", duration: 300 } 
     }); 

     $('#calendar').fullCalendar({ 
      header: { 
       left: 'prev,next today', 
       center: 'title', 
       right: 'month,basicWeek,basicDay' 
      }, 
      selectable: true, 
      selectHelper: true, 
      dayclick: function(date){ 

      }, 
      select: function (date, start, end) { 
       if ($('#job').attr('class') === 'XXX') { 
        EMP.calendarPopup(date, start, end); 
       } 
      }, 
      eventSources: [ 
       { 
        url: '/Home/getAllEvents/', 
        data: { Locations: loc }, 
        type: 'POST' 
       } 

      ], 
      eventClick: function (event, element, date) { 


       EMP.editCalendarPopup(date, event); 



      }, 
      height: 350, 
      defaultView: 'basicWeek', 
      editable: true, 
      eventLimit: true, // allow "more" link when too many events 
      eventRender: function (data, element) { 


       var start = moment(data.start._i).format('LT'); 
       var end = moment(data.end._i).format('LT');    
      } 
     }); 
    }, 

    editCalendarPopup: function (date, event) { 

     $('.calendar-popup').addClass('active edit'); 

     var event_date = event.start._i.split("T")[0]; 

     var start = event.start._i.split("T")[1] 
     var end = event.end._i.split("T")[1]; 

     start = EMP.convert12hr(start); 
     end = EMP.convert12hr(end); 

     var startTime = start.split(' ')[0]; 
     var startMod = start.split(' ')[1]; 
     var endTime = end.split(' ')[0]; 
     var endMod = end.split(' ')[1]; 


     $('#date').val(event_date); 

     $('#calendar-event').val(event.title); 
     $('#calendar-custodian').val(event.cust); 
     $('#calendar-start').val(startTime); 
     $('#startampm').val(startMod) 
     $('#calendar-end').val(endTime); 
     $('#endampm').val(endMod); 

     $('#hiddenEvent').val(event.title); 
     $('#hiddenCustodian').val(event.cust); 
     $('#hiddenStart').val(event.start._i); 
     $('#hiddenEnd').val(event.end._i); 
     $('#hiddenId').val(event._id); 


    }, 

    editCalendarAjax: function() { 

     var event = $("#calendar").fullCalendar('clientEvents'); 

     var hiddenId = $('#hiddenId').val(); 

     event = $.grep(event, function(e){return e._id === hiddenId}); 

     event = event[0]; 


     var event_date = $('#date').val(); 


     var title = $('#calendar-event').val(); 
     var cust = $('#calendar-custodian').val(); 

     var start = $('#calendar-start option:selected').val(); 
     var end = $('#calendar-end option:selected').val(); 
     var startampm = $("#startampm option:selected").val(); 
     var endampm = $("#endampm option:selected").val(); 
     start = start + " " + startampm; 
     end = end + " " + endampm; 

     start = EMP.convert24hr(start); 
     end = EMP.convert24hr(end); 

     var locCode = $('.location').attr('id'); 

     var date_start = event_date + "T" + start; 
     var date_end = event_date + "T" + end; 

     if (title) { 
      event = { 
       title: title, 
       start: date_start, 
       cust: cust, 
       end: date_end 
      }; 
      $('#calendar').fullCalendar('updateEvent', event); 
     } 

     var origEvent = $('#hiddenEvent').val(); 
     var origCust = $('#hiddenCustodian').val(); 
     var origStart = $('#hiddenStart').val(); 
     var origEnd = $('#hiddenEnd').val(); 

     item = {}; 

     item["title"] = title; 
     item["cust"] = cust; 
     item["start"] = date_start; 
     item["end"] = date_end; 
     item["locCode"] = locCode; 
     item["origEvent"] = origEvent; 
     item["origCust"] = origCust; 
     item["origStart"] = origStart; 
     item["origEnd"] = origEnd; 


     $.ajax({ 
      type: "POST", 
      url: "/Home/updateCalendar", 
      data: item, 
      success: function() { 
       console.log('success!'); 
      }, 
      error: function (xhr, ajaxOptions, thrownError) { 
       window.alert("Please click here to refresh your session"); 
       console.log('error') 

      } 
     }); 


     $('#calendar').fullCalendar('unselect'); 

     EMP.togglePopups(); 


    }, 

답변

1

문제는 내가 FullCalendar의 이전 버전을 사용 하였다 :

여기 내 코드입니다. 업데이트 후 오류가 발생하지 않았습니다. 내 이벤트를 덮어 쓰기 때문에

if (title) { 
      event.title = title; 
      event.start = date_start; 
      event.cust = cust; 
      event.end = date_end; 

      $('#calendar').fullCalendar('updateEvent', event); // stick? = true 
     } 

이에

if (title) { 
    event = { 
      title: title, 
      start: date_start, 
      cust: cust, 
      end: date_end 
     }; 
     $('#calendar').fullCalendar('updateEvent', event); 
    } 

: 나는 변경했다

한가지 더이 있었다. 모든 것이 지금 작동합니다.