【发布时间】:2026-01-30 07:40:01
【问题描述】:
我正在使用完整的日历插件,因此我加载了当月的数据,但是当我单击上一个时,然后再单击下一个,然后再次上一个;我以前的事件被重复了。 例如,如果我在 11 月有一个 id=1 的活动,而我在 12 月,我去 11 月;然后我看到我的 id=1 事件重复了。 这是我的json:
[{"id":2024,"title":"titulo0","start":"2014-12-23 19:22:17","end":"2014-12-23 19:22:17","description":"descripcion0"}]
这是我加载日历的方式:
function loadEventos() {
var current_url = '';
var new_url = '';
$('#calendar').fullCalendar({
events: '/pushCombos/calendarioAction!getEventosMes.action?mes=' + 1,
header: {
left: 'prev,next today',
center: 'title',
right: ''
},
editable: true,
droppable: true, // this allows things to be dropped onto the calendar
drop: function() {
// is the "remove after drop" checkbox checked?
if ($('#drop-remove').is(':checked')) {
// if so, remove the element from the "Draggable Events" list
$(this).remove();
}
},
eventClick: function(calEvent, jsEvent, view) {
calEvent.title = "CLICKED!";
console.log(moment(calEvent.end).format("YYYY-MM-DD"));
editarEvento(calEvent);
console.log(moment(calEvent.end).format("YYYY-MM-DD"));
$('#calendar').fullCalendar('updateEvent', calEvent);
}
});
}
这是我的按钮代码:
$('.fc-button-group').children().eq(1).click(function(){
var date = $("#calendar").fullCalendar('getDate');
var month_int = moment(date).format("MM");
var year_int = moment(date).format("YYYY");
var events = {
url: '/pushCombos/calendarioAction!getEventosMes.action?mes=1',
data: {
month: month_int,
year: year_int
}
};
$('#calendar').fullCalendar('removeEventSource', events);
$('#calendar').fullCalendar('addEventSource', events);
});
当我编辑一个事件并重新加载它时;它重新加载很好,但如果我使用下一个和上一个按钮,事件就会重复。 为什么会这样?? 提前致谢!
【问题讨论】:
标签: javascript jquery calendar fullcalendar