0

我有一个 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();
        }

    });

});
4

1 回答 1

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"
}
于 2013-01-18T14:44:08.143 回答