简体   繁体   English

需要帮助将事件添加到Javascript日历

[英]Need help adding events to a Javascript Calendar

I'm trying to create a simple event calendar that has a changing background for each month. 我正在尝试创建一个简单的事件日历,该事件日历每个月都有变化。 I have looked at fullCalendar, but couldn't figure out how to add a background to each month. 我已经看过fullCalendar,但是不知道如何为每个月添加背景。 So I found this calendar code: http://www.java2s.com/Code/JavaScript/GUI-Components/Calendarwithimageforeachmonth.htm 因此,我找到了以下日历代码: http : //www.java2s.com/Code/JavaScript/GUI-Components/Calendarwithimageforeachmonth.htm

I'm using the above code, and I've modified it to create a different background for each month. 我正在使用上面的代码,并且已经对其进行了修改以为每个月创建不同的背景。 Now all I need to do is add about 8 events to the calendar. 现在,我要做的就是在日历中添加大约8个事件。 I know that fullCalendar does this via the following code: 我知道fullCalendar会通过以下代码执行此操作:

    $(document).ready(function() {

    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

    $('#calendar').fullCalendar({
        editable: true,
        events: [
            {
                title: 'All Day Event',
                start: new Date(y, m, 1)
            },
            {
                title: 'Long Event',
                start: new Date(y, m, d-5),
                end: new Date(y, m, d-2)
            },
            {
                id: 999,
                title: 'Repeating Event',
                start: new Date(y, m, d-3, 16, 0),
                allDay: false
            },
            {
                id: 999,
                title: 'Repeating Event',
                start: new Date(y, m, d+4, 16, 0),
                allDay: false
            },
            {
                title: 'Meeting',
                start: new Date(y, m, d, 10, 30),
                allDay: false
            },
            {
                title: 'Lunch',
                start: new Date(y, m, d, 12, 0),
                end: new Date(y, m, d, 14, 0),
                allDay: false
            },
            {
                title: 'Birthday Party',
                start: new Date(y, m, d+1, 19, 0),
                end: new Date(y, m, d+1, 22, 30),
                allDay: false
            },
            {
                title: 'Click for Google',
                start: new Date(y, m, 28),
                end: new Date(y, m, 29),
                url: 'http://google.com/'
            }
        ]
    });

});

I am relatively new to editing/learning javascript, so I'm not sure where to begin. 我相对较不熟悉JavaScript的编辑/学习,所以我不确定从哪里开始。 I am trying to incorporate that fullCalendar code into the calendar that I've modified from the code in the above link. 我正在尝试将fullCalendar代码合并到我根据上述链接中的代码修改的日历中。

For example, I want to add "Independance Day" to July 4th. 例如,我想在7月4日添加“独立日”。

Any help is much appreciated! 任何帮助深表感谢!

Thanks! 谢谢!

You just need to add an event to a specific date you want to . 您只需要将事件添加到想要的特定日期。 like, 喜欢,

 events: [
        {
            title: 'Independence Day',
            start: new Date(2014, 06, 4)
        }];

This will add a event for the independence day to your calendar. 这会将独立日的活动添加到您的日历中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM