gpt4 book ai didi

javascript - 更改月份时清除过滤器

转载 作者:行者123 更新时间:2023-12-02 16:51:32 25 4
gpt4 key购买 nike

我有以下代码,它按日期、项目内容等过滤 FullCalendar。我遇到的问题是,当月份更改时,不遵守过滤器。看起来日历在内部缓存了初始源。

有人可以帮忙吗?

$(document).ready(function () {

$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
editable: true,
events: getUrl()
});

$('#siteSelect').click(function () {

$('#calendar').fullCalendar('removeEvents');
$('#calendar').fullCalendar('removeEventSource', '');
$('#calendar').fullCalendar('addEventSource', getUrl());


});

function getUrl() {
return 'api/Event?' + getFilter();
}

$("#toggleButton").click(function () {
$("#toggleDiv").slideToggle("slow");

});

});

function getFilter() {
return $("#filterForm").serialize();

}

最佳答案

尝试使用函数来代替

$('#calendar').fullCalendar({
events: function(start, end, timezone, callback) {
$.ajax({
url: getUrl(),
dataType: 'JSON',
success: function(data) {
callback(JSON.parse(data));
}
});
}
...
});

关于javascript - 更改月份时清除过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26568833/

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