嘿,我需要从jquery weekcalendar切换到fullcalendar,我在理解添加新事件方面遇到了麻烦。在weekcalendar中它很简单,我触发addEvent函数,打开对话框,我有我的表单并用ajax保存一切正常。我也有一个选择框,其中的所有时间都来自当天的第一小时和结束时段的设置。是否可以在fullcalendar中使用simmilar? Weekcalendar有getTimeslotTimes()来处理时间并且很容易用它来操作,fullcalendar中这个函数的名称是什么?
干杯
答案 0 :(得分:4)
您可以使用dayclick事件:
var calendar = $('#calendar');
calendar.fullCalendar({
dayClick: function(date, allDay, jsEvent, view) {
calendar.fullCalendar('renderEvent', { title: 'YOUR TITLE', start: date, allDay: true }, true );
}
});
答案 1 :(得分:0)
<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'
}
]
});