我有一个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 :(得分: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"
}