2013-01-18 32 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調用。你可以做另一個點擊和更新數據庫中的背景顏色? – Barbs

+0

我已經這樣做了,但我的代碼沒有工作。 我不知道如何獲取活動的ID,請幫助我的代碼。 – user2424628

+0

也幫助我如何從數據庫中獲取顏色變化的價值。 – user2424628

回答

0

您是否閱讀過API?

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

這裏是你如何與事件生成功能做到這一點:

...... 
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_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" 
} 
相關問題