2013-01-18 2 views
0

이벤트가 표시되는 JQuery 이벤트 캘린더가 있습니다. 이벤트의 배경색을 변경하고 영구적 인 값을 삽입하는 클릭 기능이 필요합니다. 색상 변경. 또한 변경된 색상 이벤트 캘린더를 실행하는 코드가 필요합니다. 내 일정 캘린더 코드입니다 ...mysql 데이터베이스에 값을 삽입하여 jquery 이벤트 캘린더의 이벤트 배경색을 변경하십시오.

$(document).ready(function() { 

    $('#Uploaded').hide(); 

    $('#chang').click(function() { 
     $('#Uploaded').show('slow'); 
    }); 

    $('#chang2').click(function() { 
     $('#Uploaded').show('slow'); 
    }); 

    $('.fc-event-skin').live("click", function() { 
     $(this).css('background-color', '#090'); 
     $(this).css('border-color', '#090'); 
    }); 

    $('#calendar').fullCalendar({ 

     editable: true, 
     eventColor: '#cd3427',  
     events: "json-events.php",  
     buttonText: { 
      today: 'idag' 
     }, 
     monthNames: ['Januari', 'Februari', 'Mars', 'April', 'Maj', 'Juni', 'Juli', 
        'Augusti', 'September', 'Oktober', 'November', 'December'],  
     dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 
        'Thursday', 'Friday', 'Saturday'], 

     eventDrop: function (event, delta) { 

      $.ajax({ 
       type: "POST", 
       url: "drag.php", 
       data: "date=" + delta + "&id=" + event.id, 
       success: function (msg) { 
        //alert("Data Saved: " + "id="+ event.id +"&date="+ delta); 
       } 
      }); 

     }, 

     loading: function (bool) { 
      if (bool) $('#loading').show(); 
      else $('#loading').hide(); 
     } 

    }); 

}); 
+0

이미 eventDrop에 대한 ajax 호출을 수행하고 있습니다. 당신은 클릭을위한 또 다른 하나를 할 수 있고 그것으로 db의 백그라운드 컬러를 업데이트합니까? – Barbs

+0

나는 그것을했지만 내 코드가 작동하지 않았다. 이벤트 ID를 얻는 방법을 모르겠다. 코드를 도와주세요. – user2424628

+0

또한 색상 변경을 위해 데이터베이스에서 그 값을 얻는 방법을 알려주십시오. – user2424628

답변

0

API를 읽었습니까?

...... 
events: function (start, end, callback) { 
    $.ajax({ 
     url: url, 
     data: "json-events.php", 
     success: function (data) { 
      console.log(data); 
      //console.log is to see what you are receiving from server actually (event text,color,id....whaever you send), use google chrome, press F12 to open console 
      //here you do whatever you want with your data fetched from server if any modification required 
      //just make it look like this finally 
      //[event0,event1,event2,.....] 
      //Where your event array elements are javascript objects 
      //finally give the array to the calendar: 

      //callback([event0,event1,event2,.....]) 
     }, 
     dataType: /* xml, json, script, or html */ 
    }); 
}, 
.... 

어떻게 배열 내의 각 이벤트 객체가 생겼 : 당신은 이벤트 생성 기능을 어떻게 여기

http://arshaw.com/fullcalendar/docs/event_data/Event_Source_Object/#options

은? http://arshaw.com/fullcalendar/docs/event_data/Event_Object/ 이벤트 속성은 내가 위에 게시 한 페이지에 있지만 어쨌든 선택적 속성과 필수 속성을 가진 javascript 개체입니다! 나는 모두 목록으로보기를주고있다! 귀하의 경우에 유용하다고 자신을 결정하십시오 :

{ 
    id: "id value", 
    end: "end date", //when event ends - required field 
    start: "start date", // when event starts - required field 
    title: "title value", 
    textColor: "color value", 
    className: "add your style Class", 
    backgroundColor: "color value", 
    borderColor: "color value", 
    editable: "boolean value" 
} 
관련 문제