我在更改添加事件时遇到问题,而不是在我的完整日历中弹出提示。我已经尝试了一些来自 SO 示例的解决方案:Full Calendar Add event not via promot ?
这个解决方案现在对我有用,但只有一次!当我单击日历时,会弹出工作,事件存储到我的数据库中。但是当我尝试通过单击添加下一个事件时,仍然有来自上一个事件的文本,当我尝试使用提交按钮更改并添加下一个事件时,什么也没有发生。无法添加下一个事件,只能在刷新网站后添加。
无论如何,这是我的弹出代码:
$(document).ready(function () {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
aspectRatio: 1.45,
droppable: true,
weekend: true,
firstHour: 7,
columnFormat: {
month: 'dddd',
week: 'ddd, dS',
day: 'dddd, MMM dS'
},
header: {
right: 'prev,next',
center: 'title',
left: 'month,agendaWeek,agendaDay'
},
viewDisplay: function(view) {
try {
setTimeline();
} catch(err) {}
},
agenda: 'h:mm{ - h:mm}',
'': 'h(:mm)t',
drop: function (date, allDay) {
var originalEventObject = $(this).data('eventObject');
var copiedEventObject = $.extend({}, originalEventObject);
copiedEventObject.start = date;
copiedEventObject.end = new Date(date.getDate()+2);
copiedEventObject.allDay = allDay;
start = $.fullCalendar.formatDate(copiedEventObject.start, "yyyy-MM-dd HH:mm:ss");
end = $.fullCalendar.formatDate(copiedEventObject.end, "yyyy-MM-dd HH:mm:ss");
$.ajax({
url: '<?php echo SITEURL; ?>/fullcalendar/add_events.php',
data: 'title=' + copiedEventObject.title + '&start=' +start + '&end=' +end + "&backgroundColor=" + copiedEventObject.backgroundColor + '&creator=<?php print_r($_SESSION["uid"]); ?>',
type: "POST",
success: function (response) {
console.log(response);
$('#calendar').fullCalendar('refetchEvents');
}
});
if ($('#drop-remove').is(':checked')) {
$(this).remove();
}
},
editable: true,
defaultView: 'agendaWeek',
firstDay: 1,
handleWindowResize: true,
dragOpacity: 0.7,
allDayDefault: false,
events: "<?php echo SITEURL; ?>/fullcalendar/events.php?creator=<?php print_r($_SESSION['uid']); ?>",
timeFormat: 'HH:mm { - HH:mm}',
selectable: true,
selectHelper: true,
select: function (start, end, allDay) {
$(".popup").show();
$(".submitForm").click(function(){
var title = $(".title").val();
if (title) {
start = $.fullCalendar.formatDate(start, "yyyy-MM-dd HH:mm:ss");
end = $.fullCalendar.formatDate(end, "yyyy-MM-dd HH:mm:ss");
$.ajax({
url: '<?php echo SITEURL; ?>/fullcalendar/add_events.php',
data: 'title=' + title + '&start=' + start + '&end=' + end + '&creator=<?php print_r($_SESSION["uid"]); ?>',
type: "POST",
success: function (json) {
console.log(json);
$('#calendar').fullCalendar('refetchEvents');
}
});
console.log("start " + start + " end " + end);
}
calendar.fullCalendar('unselect');
$(".popup").hide();
});
$(".exit").click(function(){
// clear all info, unselect events and...
$(".popup").hide();
});
},
eventDrop: function (event, delta) {
start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");
end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");
$.ajax({
url: '<?php echo SITEURL; ?>/fullcalendar/update_events.php',
data: 'title=' + event.title + '&start=' + start + '&end=' + end + '&id=' + event.id,
type: "POST",
success: function (response) {
console.log(response);
}
});
},
eventClick: function (event, jsEvent, view) {
if (confirm("Really delete event " + event.title + "with id " + event.id + "?") ) {
$.ajax({
url: "<?php echo SITEURL; ?>/fullcalendar/delete_event.php",
data: 'eid='+event.id,
type: "POST",
success: function (response) {
console.log(response);
calendar.fullCalendar('removeEvents', event.id);
}
});
}
},
eventResize: function (event) {
start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");
end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");
$.ajax({
url: '<?php echo SITEURL; ?>/fullcalendar/update_events.php',
data: 'title=' + event.title + '&start=' + start + '&end=' + end + '&id=' + event.id,
type: "POST",
success: function (response) {
console.log(response);
}
});
}
});
$('#external-events div.external-event').each(function () {
var eventObject = {
title: $.trim($(this).text()),
backgroundColor : $.trim($(this).attr('bgc'))
};
$(this).data('eventObject', eventObject);
$(this).draggable({
zIndex: 999,
revert: true,
revertDuration: 0
});
});
});
我的html:
<div class="popup" style="display:none; position:fixed; top:25%; left:25%; background-color:white;">
<input class"title" type="text" size="26" />
<a href="#" onclick="return false" class="submitFrom">submit</a> 
<a href="#" onclick="return false" class="exit">cancel</a>
</div>
我将非常感谢任何帮助。多谢 !!!!!提交 取消