jQuery 下一个和上一个完整日历

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5082011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 18:32:23  来源:igfitidea点击:

fullcalendar next and prev

jqueryfullcalendar

提问by Faiyet

Only yesturday I started to use the jquery fullcarlendar plugin. Now What I am trying to do is on clicking the next or prev buttons I am doing a jquery

就在昨天我开始使用 jquery fullcarlendar 插件。现在我要做的是点击下一个或上一个按钮我正在做一个 jquery

$('#element').load('some_url_here') 

How exactly do I use the next and previous methods to do something like

我究竟如何使用下一个和上一个方法来做类似的事情

 $('#calendar').fullCalendar({
    prev: function(){
        $('#calendar').load("events/findbymonth/"+$('#calendar').fullCalendar('getDate').getMonth());
    },
    next: function(){
        $('#calendar').load("events/findbymonth/"+$('#calendar').fullCalendar('getDate').getMonth());
    },
    title: "My Title",
    events: jsonString,
    editable: false,
    disableDragging: true
});

All I need for my url is the next month. Do I have to manually increment the current month for next and decrement for previous? Is there a "getCurrentMonth()" method which I can call directly? Something like $('#calendar').load("events/findbymonth/"+$('#calendar').fullCalendar.getCurrentMonth());

我的网址只需要下个月。我是否必须手动增加下个月的当前月份并减少上一个月份?是否有可以直接调用的“getCurrentMonth()”方法?就像是 $('#calendar').load("events/findbymonth/"+$('#calendar').fullCalendar.getCurrentMonth());

Thanks, guys

谢谢你们

回答by justkt

When the next and previous buttons are clicked, calls are automatically made to the event sources you specify - you don't have to do a manual load. Prev and next are used to programmatically move the calendar as opposed to being used to specify hooks for overriding the default behavior.

单击下一个和上一个按钮时,将自动调用您指定的事件源 - 您不必手动加载。Prev 和 next 用于以编程方式移动日历,而不是用于指定用于覆盖默认行为的挂钩。

FullCalendar sends requests for events as follows: /events/find/?start=1262332800&end=1265011200&_=1263178646

FullCalendar 发送事件请求如下: /events/find/?start=1262332800&end=1265011200&_=1263178646

When you click on next and previous, it gets the time since the epoch of the start of the month and the time since the epoch of the end of the month and uses those as parameters for start and end. The _ parameter is unique per call to prevent caching.

当您单击下一个和上一个时,它会获取自本月开始的纪元以来的时间和自月末的纪元以来的时间,并将它们用作开始和结束的参数。_ 参数在每次调用时都是唯一的,以防止缓存。

According to the documentationyou can change the parameter names startand endbut not the values. To change those values you'd have to modify FullCalendar itself.

根据文档,您可以更改参数名称startend但不能更改值。要更改这些值,您必须修改 FullCalendar 本身。

Assuming you can change the code that sends your JSON, I'd suggest changing to code that takes seconds since the epoch values as input and return events based on that. If you can't do that, start looking into modifying the FullCalendar source to meet your needs.

假设您可以更改发送 JSON 的代码,我建议更改为从纪元值作为输入并基于此返回事件需要几秒钟的代码。如果您不能这样做,请开始研究修改 FullCalendar 源以满足您的需要。

回答by la_antorcha

I know is late, but if somenone has the same problem this is how you make cutom navigation controls:

我知道已经晚了,但是如果有人遇到同样的问题,这就是您制作自定义导航控件的方式:

$('#btnNext').click(function() {
    $('#calendar').fullCalendar('next');
});     
$('#btnPrev').click(function() {
    $('#calendar').fullCalendar('prev');
});

回答by Maidot

Some likely problem is answered here: jQuery FullCalendar click 'next' event notificatin

这里回答了一些可能的问题: jQuery FullCalendar click 'next' event notificatin