我在每天/单元格中添加了(' +')按钮。
var add_button = '<input type="button" value="+" />';
$(".fc-day-number").prepend(add_button);
如何在点击此按钮后添加活动(&#39; +&#39;)按钮,只需点击任何一天即可执行相同操作:
dayClick: function(date) {
addEvent(date);
},
function addEvent(date) {
var newEvent = {
title: timeSlot,
start: date.format()
};
}
答案 0 :(得分:0)
单击该按钮时,您可以打开一个对话框。 Dialog是一个接受值的表单。保存表单后,您可以执行jquery ajax调用以将其保存到存储中。
dayClick: function (date, allDay, jsEvent, view) {
$('#eventTitle').val("");
$('#eventDate').val($.fullCalendar.formatDate(date, 'dd/MM/yyyy'));
$('#eventTime').val($.fullCalendar.formatDate(date, 'HH:mm'));
ShowEventPopup(date);
},
function ShowEventPopup(date) {
$('#popupEventForm').modal('show');
$('#eventTitle').focus();
}
$('#btnPopupSave').click(function () {
$('#popupEventForm').hide();
var dataRow = {
'Title': $('#eventTitle').val(),
'NewEventDate': $('#eventDate').val(),
'NewEventTime': $('#eventTime').val(),
'NewEventDuration': $('#eventDuration').val()
}
ClearPopupFormValues();
$.ajax({
type: 'POST',
url: "/Diary/SaveEvent",
data: dataRow,
success: function (response) {
if (response == 'True') {
$('#calendar').fullCalendar('refetchEvents');
alert('New event saved!');
}
else {
alert('Error, could not save event!');
}
}
});
});