简体   繁体   English

全日历添加事件

[英]Fullcalendar Add Event

Hey, I need to switch from jquery weekcalendar to fullcalendar and I am having troubles with understanding of adding new events. 嘿,我需要从jquery weekcalendar切换为fullcalendar,在理解添加新事件方面遇到了麻烦。 In weekcalendar its easy, I trigger the addEvent functions, open the dialog box and there I have my form and save everything ok with ajax. 在Weekcalendar简单易用的情况下,我触发了addEvent函数,打开对话框,然后有了表单,并使用ajax保存了所有内容。 I also have a selectbox where are all times from the settings of first hour and end hour of the day. 我还有一个选择框,所有时间都从一天的第一小时和结束时间开始。 Is it possible to have something simmilar in fullcalendar? 全日历中是否可能有类似的东西? Weekcalendar has getTimeslotTimes() which deals with the time and it is easy to operate with it, what is the name of such function in fullcalendar? Weekcalendar具有用于处理时间的getTimeslotTimes(),并且操作起来很容易,fullcalendar中此类函数的名称是什么?

Cheers 干杯

You can use the dayclick event: 您可以使用dayclick事件:

var calendar = $('#calendar');
calendar.fullCalendar({
    dayClick: function(date, allDay, jsEvent, view) {
        calendar.fullCalendar('renderEvent', { title: 'YOUR TITLE', start: date, allDay: true }, true );
    }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://momentjs.com/downloads/moment.min.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.1.0/fullcalendar.js'></script>
<link rel='stylesheet' href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.1.0/fullcalendar.min.css" />
$('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },
    //defaultDate: '2014-06-12',
    defaultView: 'month',
    editable: true,
    events: [
        {
            title: 'All Day Event',
            start: '2019-11-11'
        },
        {
            title: 'Long Event',
            start: '2019-09-09',
            end: '2019-11-11'
        },
        {
            id: 999,
            title: 'Repeating Event',
            start: '2019-06-11T16:00:00'
        },
        {
            id: 999,
            title: 'Repeating Event',
            start: '2019-06-11T16:00:00'
        },
        {
            title: 'Meeting',
            start: '2019-06-11T10:30:00',
            end: '2014-06-12T12:30:00'
        },
        {
            title: 'Lunch',
            start: '2019-11-12T12:00:00'
        },
        {
            title: 'Birthday Party',
            start: '2019-11-13T07:00:00'
        },
        {
            title: 'Click for Google',
            url: 'http://google.com/',
            start: '2019-11-28'
        }
    ]
});

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

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