2013-08-28 3 views
2

fullcalendar에서 json을 업데이트하고 싶습니다. 여기 정확히하려는 것입니다. 전체 캘린더의 일정 개체에 직접 입력하려고하는 JSON 문자열이 있습니다.fullCalendar에서 이벤트를 업데이트하는 방법은 무엇입니까?

->

var JSON[ 
    { 
     "id": "1", // Optional 
     "title": "Demo event", // Required 
     "start": "2013-08-28 10:20:00", // Required 
     "end": "2013-08-28 11:00:00", // Optional 
     "allDay": false, // Optional 
     "url": "http://google.com", // Optional, will not open because of browser-iframe security issues 
     "className": "test-class", // Optional 
     "editable": true, // Optional 
     "color": "yellow", // Optional 
     "borderColor": "red", // Optional 
     "backgroundColor": "yellow", // Optional 
     "textColor": "green" // Optional 
    }, 
    { 
     "id": "2", // Optional 
     "title": "Demo event 2", // Required 
     "start": "2013-08-27 10:20:00", // Required 
     "end": "2013-08-27 11:00:00", // Optional 
     "allDay": false, // Optional 
     "url": "http://google.com", // Optional, will not open because of browser-iframe security issues 
     "className": "test-class", // Optional 
     "editable": true, // Optional 
     "color": "yellow", // Optional 
     "borderColor": "red", // Optional 
     "backgroundColor": "yellow", // Optional 
     "textColor": "green" // Optional 
    } 
]; 

,

그럼 난 새로운 문자열에 이벤트까지 드롭 (바이올린에 도시하지 않음)에 JSON을 수정하고 새 이벤트에 가려고 할

달력.

전체 캘린더가 적용되지 않습니다. 도움을

http://jsfiddle.net/pratik24/u8Ksw/28/

감사합니다. 고맙습니다.

답변

6

새 이벤트를 렌더링하기 위해 올바른 fullCalendar 메서드를 호출하지 않습니다.

이 단지 주변에 처음으로 이벤트를 렌더링하기위한 것입니다 때문에 작동하지 않습니다 :

$("#demo-calendar").fullCalendar('removeEvents'); 
    $("#demo-calendar").fullCalendar('addEventSource', JSON); 

:

$("#demo-calendar").fullCalendar('renderEvents', JSON); 

가 대신 달력에 이벤트를 제거하고 새로 고침 할 필요가 피들을 확인하십시오 : http://jsfiddle.net/shaunp/u8Ksw/29/

이라는 fullCalendar 방법이 있습니다.,하지만 만든 이벤트와 같은 일련의 이벤트에서는 작동하지 않으므로 수동으로 이벤트를 제거한 다음 이벤트 원본을 다시 추가해야합니다.

+0

감사합니다. 이것은 내가 실제로 찾고 있었던 것이다. 그러나 could not는 계산한다. – patz

관련 문제