gpt4 book ai didi

javascript - 为什么当我单击下一个或上一个时,完整日历 jquery 插件无法按预期工作?

转载 作者:行者123 更新时间:2023-12-03 11:10:16 25 4
gpt4 key购买 nike

我正在使用完整的日历插件,因此我加载了当月的数据,但是当我单击“上一个”、“下一个”、“上一个”时;我以前的事件被重复了。例如,如果我在 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);
});

当我编辑事件并重新加载它时;它重新加载得很好,但如果我使用下一个和上一个按钮,事件就会重复。为什么会出现这种情况??提前致谢!

最佳答案

尝试将您的事件选项更改为:

events: { 
url: '/pushCombos/calendarioAction!getEventosMes.action',
type: 'GET',
data: {
mes: 1
},
cache: false,
error: function (jqXHR, textStatus, errorThrow) { //whatever you want }
}

关于javascript - 为什么当我单击下一个或上一个时,完整日历 jquery 插件无法按预期工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27630314/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com